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

[v2.8] [backport] AzureAD support #363

Merged
merged 17 commits into from
May 31, 2024

Conversation

enrichman
Copy link
Contributor

@enrichman enrichman commented Apr 23, 2024

@enrichman enrichman marked this pull request as ready for review May 27, 2024 14:40
Copy link
Contributor

@crobby crobby left a comment

Choose a reason for hiding this comment

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

Looks great

@samjustus samjustus requested review from pmatseykanets and removed request for andreas-kupries and JonCrowther May 30, 2024 14:14
@enrichman enrichman merged commit 1d80411 into rancher:v2.8 May 31, 2024
1 check passed
Copy link

@bigkevmcd bigkevmcd left a comment

Choose a reason for hiding this comment

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

Looks good I think the error messages can be improved tho'

i++
data := gjson.GetBytes(response, "data").Array()

supportedProviders := []TypedProvider{}

Choose a reason for hiding this comment

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

the nil slice is the preferred style

https://go.dev/wiki/CodeReviewComments#declaring-empty-slices

I'll be honest, this surprises me, and I am guilty of not doing this :-)


err = json.Unmarshal([]byte(provider.Raw), typedProvider)
if err != nil {
return nil, err

Choose a reason for hiding this comment

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

We could maybe wrap this with something that says "attempting to decode the auth provider of type %s", otherwise these sorts of errors are quite generic (and thus opaque).

if err != nil {
return nil, err
if !gjson.ValidBytes(response) {
return nil, errors.New("invalid JSON input")

Choose a reason for hiding this comment

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

How about "response" here rather than "input"? and could we include the authProviderURL which might point to why?

func Test_getAuthProviders(t *testing.T) {

setupServer := func(response string) *httptest.Server {
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {

Choose a reason for hiding this comment

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

The servers created by this aren't .Closed() ?

Probably won't impact in the scope of tests.

Reading the code tho', it feels like you could create and either defer .Close() or t.Cleanup() and close?

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.

[2.8] Rancher CLI doesn't have a driver for AzureAD for authenticating with kubectl
4 participants