-
Notifications
You must be signed in to change notification settings - Fork 38
feat(RBAC): enable project-scoped API tokens #2143
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
Conversation
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
Signed-off-by: Miguel Martinez <miguel@chainloop.dev>
// If a project is provided, we store it in the token | ||
var projectID *uuid.UUID | ||
if options.project != nil { | ||
projectID = ToPtr(options.project.ID) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't &options.project.ID
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it does, I was just using one way of doing it tbh, a little bit pointless it's true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I like it. Basically "RBAC" for API tokens will be enabled only if the token has a "ProjectID" claim, right?
Name: token.Name, | ||
CreatedAt: token.CreatedAt, | ||
Token: token.JWT, | ||
ProjectID: token.ProjectID, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the token has a ProjectID, is this change checking that the ProjectID in the database is the same?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mm, it is not, let me add it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I was using the projectID from the DB when in reality we need to use the one from the token.
Now I check that both match
That's correct |
This PR continues with project-scoped API tokens #2130
I tested it locally performing both attestations and regular operations with admin tokens or scoped tokens, for example this is what you get when you try to perform an attestation with a token from another project.
closes #2130