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

Add experimental whoami api endpoint #9233

Merged
merged 2 commits into from
Nov 16, 2021
Merged

Conversation

ajm188
Copy link
Contributor

@ajm188 ajm188 commented Nov 15, 2021

Signed-off-by: Andrew Mason amason@slack-corp.com

Description

We're just pulling the actor out of the current request, assuming that the actor making this request is also the actor making other requests, for the purposes of the frontend.

I added a "dumb" authenticator to test both versions, which looks like:

diff --git a/go/vt/vtadmin/rbac/authentication.go b/go/vt/vtadmin/rbac/authentication.go
index a43dcbb2e1..f5cb42f86c 100644
--- a/go/vt/vtadmin/rbac/authentication.go
+++ b/go/vt/vtadmin/rbac/authentication.go
@@ -134,6 +134,19 @@ func RegisterAuthenticator(name string, f func() Authenticator) {
        authenticators[name] = f
 }
 
+type dumbAuthn struct{}
+
+func (authn *dumbAuthn) Authenticate(ctx context.Context) (*Actor, error) { return nil, nil }
+func (authn *dumbAuthn) AuthenticateHTTP(r *http.Request) (*Actor, error) {
+       return &Actor{"andrew", []string{"role1", "role2"}}, nil
+}
+
+func init() {
+       RegisterAuthenticator("dumb", func() Authenticator {
+               return &dumbAuthn{}
+       })
+}
+

Screen Shot 2021-11-15 at 9 37 23 AM

Screen Shot 2021-11-15 at 9 38 23 AM

Related Issue(s)

Checklist

  • Should this PR be backported? no
  • Tests were added or are not required no
  • Documentation was added or is not required

Deployment Notes

Signed-off-by: Andrew Mason <amason@slack-corp.com>
@ajm188
Copy link
Contributor Author

ajm188 commented Nov 15, 2021

@doeg let me know if you want me to add struct tags to the Actor to make the Name and Roles fields lowercase json, or if it doesn't matter to you! (either is fine/easy ☺️ )

Copy link
Contributor

@doeg doeg left a comment

Choose a reason for hiding this comment

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

Thank you!!! :') If it's super easy to add struct tags for lowercase then that would tidy up the front-end a bit but if it's any more than like 1% effort it's ok!

Thanks for the lil fake auth example too.

Signed-off-by: Andrew Mason <amason@slack-corp.com>
Copy link
Contributor

@doeg doeg left a comment

Choose a reason for hiding this comment

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

🌻

@doeg
Copy link
Contributor

doeg commented Nov 16, 2021

I'm going to merge dis because I want to use it 😎

@doeg doeg merged commit f2663ec into vitessio:main Nov 16, 2021
@ajm188 ajm188 deleted the vtadmin-whoami branch November 16, 2021 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants