feat:租户隔离策略
This commit is contained in:
parent
a88776119c
commit
042eeae7ea
@ -3,6 +3,7 @@ package com.flyfish.framework.auditor;
|
||||
import com.flyfish.framework.domain.authorized.AuthorizedDomain;
|
||||
import com.flyfish.framework.domain.base.IUser;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import reactor.core.publisher.Mono;
|
||||
@ -19,6 +20,7 @@ public class ReactiveAuthorizeAuditor implements ReactiveBeanAuditor<AuthorizedD
|
||||
*/
|
||||
@Override
|
||||
public Mono<AuthorizedDomain> audit(AuthorizedDomain data) {
|
||||
if (StringUtils.isBlank(data.getAuthorizeId())) {
|
||||
return ReactiveSecurityContextHolder.getContext()
|
||||
.map(ctx -> (IUser) ctx.getAuthentication().getPrincipal())
|
||||
.map(user -> {
|
||||
@ -27,4 +29,6 @@ public class ReactiveAuthorizeAuditor implements ReactiveBeanAuditor<AuthorizedD
|
||||
})
|
||||
.defaultIfEmpty(data);
|
||||
}
|
||||
return Mono.just(data);
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,14 @@ package com.flyfish.framework.domain.authorized;
|
||||
|
||||
import com.flyfish.framework.annotations.Property;
|
||||
import com.flyfish.framework.domain.base.AuditDomain;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 带鉴权的实体,主要以部门隔绝
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public abstract class AuthorizedDomain extends AuditDomain {
|
||||
|
||||
// 作用域id,一般是部门。用户存储时插入
|
||||
|
Loading…
Reference in New Issue
Block a user