-
Notifications
You must be signed in to change notification settings - Fork 285
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
feat: Add sdf whoami endpoint accessible to user or automation tokens #5203
feat: Add sdf whoami endpoint accessible to user or automation tokens #5203
Conversation
Dependency Review✅ No vulnerabilities or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files |
bcf5b4f
to
fac5b1e
Compare
719430a
to
28d0064
Compare
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.
A few ?s
Also factors authorization so that all authorization types (and WS vs. non-WS) all run through the same extractors
28d0064
to
8aa67cf
Compare
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.
Tested this by replacing my local workspace token with one for another user (my gmail account) but for the same "workspace id" (without modifying the token, just the key on the data bag in the local storage). This seems good to me, although for something this sensitive another set of eyes might be worthwhile
I think I will wait to merge our auth stack until it's NOT 5PM on Friday. :) |
This adds a "whoami" endpoint that you can hit to check your token and email (who SI thinks you are). It mainly exists to validate that we can actually authorize automation tokens for an endpoint (since all other endpoints reject automation tokens).
Extractor Funnel
This also factors the token and authorization extractors so they always use the same code. web/automation authorization still work via extractors, they just all run through a single funnel now.
EndpointAuthorization
is the main authorization extractor you will use (orAccessBuilder
, which uses it), which:Authorization:
header using the RawAccessToken extractor.Customization For Different Endpoints
The big reason to break this up was to allow different authorization for different endpoints, as well as to support WS endpoints using the same extractors. The
AuthorizedRole
andRawAccessToken
extractors check if they already have a value before doing their default behavior, so you can invoke other extractors that set the value first. To wit:_: AuthorizeForAutomationRole
extractor to its endpoint function, causing endpoint validation to check for the automation role instead._: TokenFromQueryParam
extractor to the endpoint function, which retrieves the token from the "token" query parameter instead of the Authorization header.Where appropriate, these endpoints cache their results so that if you use multiple extractors (which we do frequently) you don't pay a double or triple database access or public key decryption penalty.
This also adds
Deref
andInto
to a lot of the extractors, which means instead of saying things likeNats(nats): Nats
you can just saynats: Nats
and still use the nats object like normal.Future
Going forward, we'll want to take some of this (RawAccessToken and ValidatedToken in particular) and move it to a common library (quite possibly repurpose
si-jwt-public-key
for it) so that the module index can use them. I started to do that, but there's a minor snarl in that it needs to be able to access the public key we grab as part ofAppState
(which isn't shared between module index and sdf). Will get back to that at a later time.