feat:仓库初始化问题修复
This commit is contained in:
parent
e5ae9766df
commit
b5884b4b86
@ -1,6 +1,7 @@
|
|||||||
package com.flyfish.framework.service;
|
package com.flyfish.framework.service;
|
||||||
|
|
||||||
import com.flyfish.framework.config.constants.UserCacheKeys;
|
import com.flyfish.framework.config.constants.UserCacheKeys;
|
||||||
|
import com.flyfish.framework.configuration.jwt.TokenProvider;
|
||||||
import com.flyfish.framework.domain.base.IUser;
|
import com.flyfish.framework.domain.base.IUser;
|
||||||
import com.flyfish.framework.domain.po.User;
|
import com.flyfish.framework.domain.po.User;
|
||||||
import com.flyfish.framework.enums.UserStatus;
|
import com.flyfish.framework.enums.UserStatus;
|
||||||
@ -17,7 +18,6 @@ import org.springframework.security.core.context.SecurityContextImpl;
|
|||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
|
import org.springframework.security.crypto.password.NoOpPasswordEncoder;
|
||||||
import org.springframework.security.web.server.context.ServerSecurityContextRepository;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.server.ServerWebExchange;
|
import org.springframework.web.server.ServerWebExchange;
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
@ -54,7 +54,7 @@ public class MongoUserDetailsServiceImpl implements MongoUserDetailsService {
|
|||||||
private final UserDetailsConverter userDetailsConverter;
|
private final UserDetailsConverter userDetailsConverter;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ServerSecurityContextRepository contextRepository;
|
private TokenProvider tokenProvider;
|
||||||
@Resource
|
@Resource
|
||||||
private ReactiveRedisOperations reactiveRedisOperations;
|
private ReactiveRedisOperations reactiveRedisOperations;
|
||||||
|
|
||||||
@ -111,7 +111,11 @@ public class MongoUserDetailsServiceImpl implements MongoUserDetailsService {
|
|||||||
@Override
|
@Override
|
||||||
public Mono<Authentication> authenticate(UserDetails user, ServerWebExchange exchange) {
|
public Mono<Authentication> authenticate(UserDetails user, ServerWebExchange exchange) {
|
||||||
return loadContext(user)
|
return loadContext(user)
|
||||||
.flatMap(securityContext -> contextRepository.save(exchange, securityContext)
|
.flatMap(securityContext -> Mono.fromCallable(() -> {
|
||||||
|
// 添加jwtToken
|
||||||
|
tokenProvider.addToken(exchange, securityContext.getAuthentication());
|
||||||
|
return Mono.empty();
|
||||||
|
})
|
||||||
.contextWrite(ReactiveSecurityContextHolder.withSecurityContext(
|
.contextWrite(ReactiveSecurityContextHolder.withSecurityContext(
|
||||||
Mono.just(securityContext)))
|
Mono.just(securityContext)))
|
||||||
.then(Mono.just(securityContext)))
|
.then(Mono.just(securityContext)))
|
||||||
@ -146,10 +150,7 @@ public class MongoUserDetailsServiceImpl implements MongoUserDetailsService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Mono<Void> logout(ServerWebExchange exchange) {
|
public Mono<Void> logout(ServerWebExchange exchange) {
|
||||||
return ReactiveSecurityContextHolder.getContext()
|
return tokenProvider.removeToken(exchange);
|
||||||
.switchIfEmpty(contextRepository.load(exchange))
|
|
||||||
.flatMap(context -> contextRepository.save(exchange, context));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user