-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1115 from neicnordic/feature/sda-admin-rbac
[API] Add a RBAC solution
- Loading branch information
Showing
18 changed files
with
749 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,12 +14,9 @@ global: | |
issuer: "" | ||
clusterIssuer: "cert-issuer" | ||
api: | ||
adminsFileSecret: | ||
adminUsers: | ||
- [email protected] | ||
- [email protected] | ||
jwtPubKeyName: jwt.pub | ||
jwtSecret: jwk | ||
rbacFileSecret: api-rbac | ||
archive: | ||
storageType: s3 | ||
s3AccessKey: PLACEHOLDER_VALUE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
log: | ||
format: "json" | ||
level: "debug" | ||
admin: | ||
users: "[email protected]" | ||
api: | ||
rbacFile: /rbac.json | ||
archive: | ||
type: s3 | ||
url: "http://s3" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"policy": [ | ||
{ | ||
"role": "admin", | ||
"path": "/c4gh-keys/*", | ||
"action": "(GET)|(POST)|(PUT)" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/file/ingest", | ||
"action": "POST" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/file/accession", | ||
"action": "POST" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/users", | ||
"action": "GET" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/users/:username/files", | ||
"action": "GET" | ||
}, | ||
{ | ||
"role": "*", | ||
"path": "/files", | ||
"action": "GET" | ||
} | ||
], | ||
"roles": [ | ||
{ | ||
"role": "admin", | ||
"rolebinding": "submission" | ||
}, | ||
{ | ||
"role": "[email protected]", | ||
"rolebinding": "admin" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,16 +136,69 @@ Admin endpoints are only available to a set of whitelisted users specified in th | |
curl -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X POST -d '{"pubkey": "'"$( base64 -w0 /PATH/TO/c4gh.pub)"'", "description": "this is the key description"}' https://HOSTNAME/c4gh-keys/add | ||
``` | ||
|
||
#### Configure Admin users | ||
#### Configure RBAC | ||
|
||
The users that should have administrative access can be set in two ways: | ||
RBAC is configured according to the JSON schema below. | ||
The path to the JSON file containing the RBAC policies needs to be passed through the `api.rbacFile` config definition. | ||
|
||
- As a comma separated list of user identifiers assigned to: `admin.users`. | ||
- As a JSON file containg a list of the user identities, the path to the file is assigned to: `admin.usersFile`. This is the recommended way. | ||
The `policy` section will configure access to the defined endpoints. Unless specific rules are set, an endpoint will not be accessible. | ||
|
||
- `action`: can be single string value i,e `GET` or a regex string with `|` as separator i.e. `(GET)|(POST)|(PUT)`. In the later case all actions in the list are allowed. | ||
- `path`: the endpoint. Should be a string value with two different wildcard notations: `*`, matches any value and `:` that matches a specific named value | ||
- `role`: the role that will be able to access the path, `"*"` will match any role or user. | ||
|
||
The `roles` section defines the available roles | ||
|
||
- `role`: rolename or username from the accesstoken | ||
- `roleBinding`: maps a user/role to another role, this makes roles work as groups which simplifies the policy definitions. | ||
|
||
```json | ||
[ | ||
"[email protected]", | ||
"[email protected]" | ||
] | ||
{ | ||
"policy": [ | ||
{ | ||
"role": "admin", | ||
"path": "/c4gh-keys/*", | ||
"action": "(GET)|(POST)|(PUT)" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/file/ingest", | ||
"action": "POST" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/file/accession", | ||
"action": "POST" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/users", | ||
"action": "GET" | ||
}, | ||
{ | ||
"role": "submission", | ||
"path": "/users/:username/files", | ||
"action": "GET" | ||
}, | ||
{ | ||
"role": "*", | ||
"path": "/files", | ||
"action": "GET" | ||
} | ||
], | ||
"roles": [ | ||
{ | ||
"role": "admin", | ||
"rolebinding": "submission" | ||
}, | ||
{ | ||
"role": "[email protected]", | ||
"rolebinding": "admin" | ||
}, | ||
{ | ||
"role": "[email protected]", | ||
"rolebinding": "submission" | ||
} | ||
] | ||
} | ||
``` |
Oops, something went wrong.