-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access control via sub claim #86
Comments
As mentioned above this structure is based on the use of the foca to easily implement it across different services:- As MongoDB is used as our default database across different services. It attaches the uniques
When user requests for the the service we can send the Service model can be:-
Any addition will be great. @uniqueg |
Thanks @git-anurag-hub! I don't understand your suggested solution fully. Some questions/comments:
Can you please clarify these issues? |
Answers as follows:-
|
Currently, anyone with a valid access token can access all the resources in the service. While this may sometimes be desirable, there are many situations where only specific people should be able to a given resource.
For now, the easiest way of granting access control to specific endpoints is by recording a user's identity when registering a resource and then, when access to that resource is requested, check that the person requesting the resource is the same person that registered it. This can be done via the JWT's
sub
claim. If a user then supplies a valid token and the correctsub
claim, they will get access. If thesub
claim does not match, a403
response should be returned.The solution to be implemented should allow some level of controlling this behavior to cover as many use cases as possible. For example, a user might want to register a tool and then only that user should be able to modify or delete that resource. However, the user may want everyone to be able to access the tool, perhaps even without providing an access token at all.
The solution should also consider later extension by checking for other specific claims in a token, e.g., those that confer some form of group membership.
Code repetition should be avoided, and usage as simple as possible. The information on who registered which resources should always be recorded in the database. The logic to check if the
sub
claim matches the one recorded could, for example, be implemented as a decorator that wraps the endpoints that should be protected against access by unauthorized users. If implemented in a sufficiently abstract manner, the code could also be put into FOCA (preferable) and corresponding config options could be implemented (e.g., a dictionary of controller functions/classes and access control configurations) there.Before starting to implement this, please draw up a detailed plan on how you plan to implement the feature so that we can discuss if/how to improve the design with respect to usability, general applicability, extensibility and the possibility to migrate the solution to FOCA so that other services can make use of it, too.
The text was updated successfully, but these errors were encountered: