-
Notifications
You must be signed in to change notification settings - Fork 22
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(HMS-3416): Switch to service accounts for dev auth #792
Conversation
internal/headers/access_token.go
Outdated
data.Add("client_id", clientId) | ||
data.Add("client_secret", clientSecret) | ||
|
||
req, err := http.NewRequest(http.MethodPost, provider.Endpoint().TokenURL, strings.NewReader(data.Encode())) |
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.
This is me being bit fancy just to resolve a static URL, for which we need extra module 🤔
provider.Endpoint().TokenURL is quite static value.
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.
Normally, I would insist on caching the token but it has some drawbacks too and since this is only for dev setups, doing it on every request is fine. Thanks.
} | ||
res.Body.Close() | ||
json.Unmarshal(body, &token) | ||
|
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.
Check return value, also use defer
to ensure body is closed.
internal/headers/headers.go
Outdated
if err != nil { | ||
return err | ||
} | ||
zerolog.Ctx(ctx).Warn().Msgf("Service account authentication: %s", clientID) |
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.
This should not be warning, maybe info or debug.
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.
This is warning, because we don't want that to happen in Stage/Prod, so this makes it easier to spot in case by some accident we allow it there.
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.
Or that was the thinking why it was a warning for basic auth, I've kept the level.
bb56af5
to
fe4810d
Compare
Yeah exactly, I was thinking about it, but then decided against it for 1) I was lazy and 2) probably not as necessary for dev only. |
2d274a1
to
b143986
Compare
For developement we have been using basic auth to authenticate against stage services. This switches the auth to Service accounts.
b143986
to
0336971
Compare
/retest |
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 with sources, thanks. Took me a while to prepare my new dev setup, apologies.
For developement we have been using basic auth to authenticate against stage services. This switches the auth to Service accounts.