This repository has been archived by the owner on Aug 30, 2022. It is now read-only.
Flagr RBAC Design #54
fenriskiba
started this conversation in
Ideas
Replies: 1 comment
-
@zhouzhuojie @marceloboeira I would love to get your feedback on this design. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We are looking to contribute RBAC via Casbin, and we were hoping to review our design with the community before we get started.
At a high level, our plan is to:
Configurations
We'll add three configs to env.go:
Model Config
In addition to the ENV configs, users will need to provide a Model Config, which will follow syntax defined by Casbin to define the following:
r = sub, obj, act
, with the following being passed to Casbin:JWTCasbinPassJWTData
is set to true,jwt
will need to be added to the Request Definition and the JWT user data will be passed in as well.This config will be loaded into Casbin at startup to initialize the Casbin Enforcer.
Policies
While the Model Config defines the format of the Policies, the specific policies will be stored in a database table created using Casbin's GORM Adapter.
We will then create the following API's to manage the policies. These APIs will be one-to-one with the APIs that Casbin provides for managing policies, so their inputs will be based on those APIs.
Enforcement
We'll add a middleware function based on Casbin's negroni-authz library that will pass information from the HTTP Request into Casbin and either allow the action or return an HTTP 401.
The middleware will first check if the request matches the
JWTAuthPrefixWhitelistPaths
orJWTAuthExactWhitelistPaths
and allow any that do.If the path is not in one of the whitelists, then it passes the username from JWTAuthUserProperty, the URL, and the HTTP Method of the request to Casbin's Enforce API and allow or deny the request based on the result.
If
JWTCasbinPassJWTData
is set to true, it will also send all the user data in the Authorization JWT to the API.Beta Was this translation helpful? Give feedback.
All reactions