Skip to content

Commit

Permalink
refactor(authentication): 优化权限配置
Browse files Browse the repository at this point in the history
  • Loading branch information
conifercone committed Dec 19, 2024
1 parent 7e4f1f9 commit b4109ee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ GrpcSecurityMetadataSource grpcSecurityMetadataSource() {
.collect(Collectors.toSet())));
} else if (grpcPolicy.isPermitAll()) {
source.set(methods, AccessPredicate.permitAll());
} else {
source.setDefault(AccessPredicate.denyAll());
} else if (grpcPolicy.isDenyAll()) {
source.set(methods, AccessPredicate.denyAll());
}
} catch (ClassNotFoundException | InvocationTargetException |
IllegalAccessException | NoSuchMethodException e) {
Expand All @@ -133,6 +133,7 @@ GrpcSecurityMetadataSource grpcSecurityMetadataSource() {
}
});
}
source.setDefault(AccessPredicate.authenticated());
return source;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ public SecurityFilterChain filterChain(HttpSecurity http, JwtDecoder jwtDecoder,
.toArray(String[]::new));
} else if (policy.isPermitAll()) {
authorizedUrl.permitAll();
} else if (policy.isDenyAll()) {
authorizedUrl.denyAll();
}
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static class Policy {

private boolean permitAll;

private boolean denyAll;
}

/**
Expand Down Expand Up @@ -86,5 +87,7 @@ public static class GrpcPolicy {
private String role;

private boolean permitAll;

private boolean denyAll;
}
}

0 comments on commit b4109ee

Please sign in to comment.