优化权限管理

This commit is contained in:
zhou-hao
2019-11-07 19:13:59 +08:00
parent 1839728a6a
commit 16e4baa732
12 changed files with 161 additions and 87 deletions

View File

@@ -18,6 +18,12 @@
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
@@ -34,10 +40,12 @@
<artifactId>reactor-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>

View File

@@ -51,14 +51,6 @@ public interface UserToken extends Serializable, Comparable<UserToken> {
long getMaxInactiveInterval();
/**
* @return 是否正常
*/
@Deprecated
default boolean isEffective() {
return isNormal();
}
default boolean isNormal() {
return getState() == TokenState.normal;
}

View File

@@ -71,12 +71,7 @@ public class UserTokenReactiveAuthenticationSupplier implements ReactiveAuthenti
context.get(ContextKey.of(ParsedToken.class))
.map(t -> userTokenManager
.getByToken(t.getToken())
.map(token -> {
if (!token.isNormal()) {
throw new UnAuthorizedException(token.getState());
}
return token;
}))
.filter(UserToken::validate))
.map(tokenMono -> tokenMono
.doOnNext(token->userTokenManager.touch(token.getToken()))
.flatMap(token -> get(thirdPartAuthenticationManager.get(token.getType()), token.getUserId())))