-
Notifications
You must be signed in to change notification settings - Fork 676
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
Implement Personal Access Tokens (PATs) #2048
Comments
@arvindh123 Please link here comments from the initial implementation you've done. |
API Keys which here mentioned are Personal Access Token PAT have scopes, PAT might or might not have full access to Magistrala. A Magistrala user can create PAT with limited scopes like Example: PAT with scopes of read only things, users, domains. This PAT could not create any entities. PAT are helps to run automation scripts without user interventions. We could not use password for automations scripts, because If authentication system have Multi-Factor authentication, then it needs human intervention, which becomes interruptions for automation scripts. If PAT is compromised, we can simply revoke it and create new . PAT might not have full access. So with compromised PAT (PAT with limited scope) no one could not do much things like beyond the scope mentioned in PAT, Example if a compromised PAT is created with read only access, then no one could not do operations like create or delete. |
PAT Data structure {
"platform": {
"users": {
"create": {},
"read": {},
"list": {},
"update": {},
"delete": {}
}
},
"domains": {
"domain_1": {
"entities": {
"groups": {
"create": {}, // this for all groups in domain
},
"channels": {
// for particular channel in domain
"delete": {
"channel1": {},
"channel2":{}
}
},
"things": {
"update": {} // this for all things in domain
}
}
}
}
} |
I'm trying to explain here challenges with example use case Lets take things share function, It requires Token for Authn and Authz. The PAT will be passed Typically, for In auth So service function could not determine on which domain request need to process. In service function, input variable id provide the thing ID. // Token - Access token / PAT encoded ID
func (svc service) Share(ctx context.Context, token, id, relation string, userids ...string) error {
user, err := svc.identify(ctx, token) // grpc identify call
// users = { user id , pat id } -> response for PAT, missing domain ID
if err != nil {
return err
}
if _, err := svc.authorize(ctx, user.GetDomainId(), auth.UserType, auth.TokenKind, user.GetId(), auth.DeletePermission, auth.ThingType, id); err != nil {
return errors.Wrap(svcerr.ErrAuthorization, err)
}
policies := magistrala.AddPoliciesReq{}
for _, userid := range userids {
policies.AddPoliciesReq = append(policies.AddPoliciesReq, &magistrala.AddPolicyReq{
SubjectType: auth.UserType,
Subject: auth.EncodeDomainUserID(user.GetDomainId(), userid),
Relation: relation,
ObjectType: auth.ThingType,
Object: id,
})
}
res, err := svc.auth.AddPolicies(ctx, &policies)
if err != nil {
return errors.Wrap(errAddPolicies, err)
}
if !res.Added {
return err
}
return nil
} Options:
"channels": {
// for particular channel in domain
"delete": {
"channel1": "domain1",
"channel2":"domain2"
}
},
ToDo:
|
@dborovcanin |
|
I'm leaning towards Badger, It looks promising for me. And we can implement distribute Badger with Raft as mentioned in previous comment |
We will need this for Dashboards sharing on our UI. |
This is blocked by the new Auth model, but it is also blocking dashboards sharing on the UI side, so we must address it in this sprint. |
This ticket is becoming urgent due to plans to use PAT in Dashboard sharing and other projects that utilize MG auth services. |
API keys will be used for communication between services. This can be done even as a separate service, but we'll first need some investigation and specs before implementing it. @arvindh123 Please write all the findings in the comment section of this issue.
The text was updated successfully, but these errors were encountered: