Implement_Access_Control_in_auth-service#3 #18
No reviewers
Labels
No labels
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Support
Type
Task
Type
Testing
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Blocks
#3 Implement Access Control in auth-service via Traefik Forward Auth
clevermicro/user-management
#15 Unit test: Implement Access Control in auth-service
clevermicro/user-management
Reference: clevermicro/user-management#18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Implement_Access_Control_in_auth-service#3"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR should be after PR #16, It contains the code for Access control using Keycloak groups and roles.
@ -89,0 +316,4 @@
* Constructs the required Keycloak Client Role name based on the HTTP method and relative path.
* Example: GET /api/jobs/{id} -> GET_api_jobs_BY_ID Example: POST /api/users -> POST_api_users
*/
private String constructRequiredRoleName(String httpMethod, String relativePath) {
If the path contains underline, this solution may not work well.
And according to this doc https://docs.cleverthis.com/en/architecture/microservices/feature-discussion/user-privilege-design, we need a lookup table to figure out which roles the user has and which role gives the access for the certain path, instead of finding roles based on url itself.
Path will never contain an underscore(underline), this: Example: GET /api/jobs/{id} -> GET_api_jobs_BY_ID
means how we automatically parse the request method and URI, here request: method=GET URI=/api/jobs/{id}
will be parsed as the role name (GET_api_jobs_BY_ID), then this role name should exist in the Keycloak roles, I showed this in the last demo, but I will show it again in the next spring review
According to the document I mentioned earlier, the role name itself shouldn't indicate the permission itself. The role name is simply a name for humans to distinguish one role from another. The permission itself is described by the role's content, as documented in the design:
The privileges grant actual access permission. And a privilege is defined here:
The resource field describes the scope of this privilege:
This is where the path lives.
Unless I'm reading out-of-date documentation (Stan shares this one in the group chat on May 1st), I didn't find any design document that matches your implementation in this PR. If you have the link to the document you're following with, please do share it. Thanks.
Also, a path can contain an underscore, since it's a valid URL. For example, a rest endpoint to manage digital books, I might give the path
/api/digital_books/
, although it looks weird and is generally not recommended (should usedigital-books
), the URL is legal and works with other systems. I couldn't see why we must add such limits to exclude underscores from URL path.Ref: https://datatracker.ietf.org/doc/html/rfc3986#section-2.3
Here is the design document for this ticket:
#2
We are implementing the ACL over Keycloak ACL capabilities as a first step.
Regarding the Stan blueprint document, we will think about it when it comes to a specific permission system.
ok, since Stan gives his approval, I can accept this PR as the first step. Although I still think the current solution is not perfect, we will improve it in the future. After all, the whole permission system is still in the early stage.
@ -0,0 +60,4 @@
}
private String getUserClientRolesEndpoint(String userId, String clientInternalId) {
return String.format("%s/admin/realms/%s/users/%s/role-mappings/clients/%s/composite",
I would be generally concerned about security when I saw string concatenation for things like SQL or URL. I did check the code and right now it's safe. But fundamentally, I can pass something like
someone?var=value#
to hijack this webclient to send something we don't want to keycloak, maybe trying to fool it to do something else and give us a false result.Ref: https://stackoverflow.com/questions/51544420/what-is-the-right-way-to-safely-concatenate-an-url-without-forgetting-a-separato/51545278#51545278
You are right. We should take care of SQL or HTML injection, but here, the string concatenation doesn't come from the request. I only know what the client name is, and the value comes from either the configuration file or from Keycloak config, nothing from the request.
@ -48,7 +47,7 @@ public class KeycloakIdentityManagerService implements IdentityManagerService {
private String getIntrospectionEndpoint() {
return String.format("%s/realms/%s/protocol/openid-connect/token/introspect",
Same url concat issue.
You are right. We should take care of SQL or HTML injection, but here, the string concatenation doesn't come from the request. I only know what the client name is, and the value comes from either the configuration file or from Keycloak config, nothing from the request.
merged with the develop branch manually.
Pull request closed