Skip to content

Commit

Permalink
Fix the comparison for when both xfcc and apikey are enabled for auth… (
Browse files Browse the repository at this point in the history
  • Loading branch information
elhametemad authored Jan 16, 2025
1 parent 30c07cd commit 673722d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Set postgres password by
export POSTGRES_PASSWORD=<my db password>
```

If config ```acdc.auth.enabled = true``` is enabled, authorization api-keys are SHA-256 hashed. The REST enb-points should include a http header key ```x-api-key``` with appropriate value.
If config ```acdc.auth.enabled = true``` is enabled, authorization api-keys are SHA-256 hashed. The REST endpoints should include a http header key ```x-api-key``` with appropriate value.

Set an environment variable for the authorized x-api-key hashed string. Example:

Expand Down
9 changes: 6 additions & 3 deletions acdc-ws/app/utils/Authorization.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ class Authorization(private var authorizationSettings: AuthorizationSettings) {
def getRoles(request: Request[_]): List[String] = {
(authorizationSettings.apiKeyAuthEnabled, authorizationSettings.xfccKeyAuthEnabled) match {
case (true, true) =>
if (getKeyRoles(request.headers.get(authorizationSettings.apiKeyAuthHeader)) ==
getXfccRoles(request.headers.get(authorizationSettings.xfccAuthHeader))) {
List(Admin)
if (!getKeyRoles(request.headers.get(authorizationSettings.apiKeyAuthHeader)).isEmpty) {
if (!getXfccRoles(request.headers.get(authorizationSettings.xfccAuthHeader)).isEmpty) {
List(Admin)
} else {
List.empty
}
} else {
List.empty
}
Expand Down
2 changes: 1 addition & 1 deletion version.sbt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ThisBuild / version := "0.11.0"
ThisBuild / version := "0.11.1"

0 comments on commit 673722d

Please sign in to comment.