Skip to content
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

Use proto options to store auth config #894

Merged
merged 5 commits into from
Sep 12, 2023

Conversation

evankanderson
Copy link
Member

Fixes #590

I was touching handler_authz.go and realized I sort of wanted to give this a spin.

Don't worry about reviewing before Monday. A couple notes:

  • GetArtifactbyName seemed to have been removed from the proto, but not the auth.
  • Some other RPCs don't seem to have any auth info in the proto -- that's because they didn't have any in handler_authz.go
  • The logic in IsRequestAuthorized is intended to be a straight port -- I'm suspicious of OBJECT_OWNER_USER, for example.

@evankanderson
Copy link
Member Author

(This was me playing around the other evening, but let's not merge before demos are done)

@JAORMX JAORMX marked this pull request as draft September 7, 2023 13:39
@JAORMX
Copy link
Contributor

JAORMX commented Sep 7, 2023

Let's get back to this next week. So far I really like it!

if !noLogMethods.Has(info.FullMethod) {
opts, err := optionsForMethod(info)
if err != nil {
// Another option: log and continue with default RPC options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to log and continue, instead it issues an error.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a "what should we do" question -- I erred on the side of failing closed, but that means that RPCs without options may not be callable (I haven't tested this by hand yet).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having RPCs without options fail is fine as long as we log it in the server and make it clear that this is the case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the comment.

@jhrozek
Copy link
Contributor

jhrozek commented Sep 7, 2023

CC @eleftherias who was looking into auth in general (not asking you for review per se unless you feel like it, just thought you'd find this interesting)

@evankanderson evankanderson changed the title LOW-PRIORITY: use proto options to store auth config Use proto options to store auth config Sep 11, 2023
@evankanderson evankanderson marked this pull request as ready for review September 11, 2023 19:05
if !noLogMethods.Has(info.FullMethod) {
opts, err := optionsForMethod(info)
if err != nil {
// Another option: log and continue with default RPC options
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think having RPCs without options fail is fine as long as we log it in the server and make it clear that this is the case.

@@ -40,6 +64,10 @@ service ArtifactService {
option (google.api.http) = {
get: "/api/v1/artifacts/{provider}"
};

option (rpc_options) = {
root_admin_only: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be owner_only? Owners should be able to list artifacts for their groups. This doesn't actually list all artifacts. I guess we also need to group scope this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was going based on the inclusion in superAdminMethods here

I agree that it doesn't seem right, but the goal here was to do a faithful translation, then fix things that seemed wrong.

I'll add a TODO.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me!


option (rpc_options) = {
auth_scope: OBJECT_OWNER_ORGANIZATION
owner_only: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhrozek I see this is currently a global fetching of artifacts; shouldn't this be a group-scoped thing instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, artifacts are always linked to repositories which AFAIK should be group-scoped. Would us supporting artifacts that come from a registry not linked to a repository make this any different? I guess not, we would still consider the registry akin to e.g. a build configuration which would be group scoped.
(the above was me thinking out loud, but in short I agree that artifacts should be group-scoped)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is for GetAuthorizationURL, which again is copied from resourceAuthorizations

I'll add another TODO to re-examine this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me, thanks @evankanderson !

@@ -180,6 +221,10 @@ service OAuthService {
post: "/api/v1/auth/{provider}/revoke"
body: "*"
};

option (rpc_options) = {
root_admin_only: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a group owner operation instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JAORMX
JAORMX previously approved these changes Sep 12, 2023
@@ -40,6 +64,10 @@ service ArtifactService {
option (google.api.http) = {
get: "/api/v1/artifacts/{provider}"
};

option (rpc_options) = {
root_admin_only: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me!


option (rpc_options) = {
auth_scope: OBJECT_OWNER_ORGANIZATION
owner_only: true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds good to me, thanks @evankanderson !

@evankanderson evankanderson merged commit acc8e03 into stacklok:main Sep 12, 2023
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace enormous map in handler_authz.go with proto annotations
3 participants