Skip to content

Commit

Permalink
Refactor: Enhance Statement.verify performance (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang authored Jan 7, 2023
1 parent 6850a25 commit ba7db16
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ interface Statement : Named, PermissionVerifier {
val conditions: List<ConditionMatcher>

override fun verify(request: Request, securityContext: SecurityContext): VerifyResult {
conditions.all {
it.match(request, securityContext)
}.let { allMatched ->
if (!allMatched) {
conditions.any {
!it.match(request, securityContext)
}.let { anyNotMatched ->
if (anyNotMatched) {
return VerifyResult.IMPLICIT_DENY
}
}
Expand Down
3 changes: 2 additions & 1 deletion cosec-gateway-server/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ cosec:
jwt:
algorithm: hmac256
secret: FyN0Igd80Gas8stTavArGKOYnS9uLWGA_

ip2region:
enabled: false
logging:
level:
root: info
Expand Down
3 changes: 2 additions & 1 deletion document/cosec-policy.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@
"actions": {
"type": "array",
"items": {
"$ref": "#/definitions/actionMatcher"
"$ref": "#/definitions/actionMatcher",
"minItems": 1
}
},
"conditions": {
Expand Down

0 comments on commit ba7db16

Please sign in to comment.