-
Notifications
You must be signed in to change notification settings - Fork 62
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
Easily addressable PR feedback #99
Changes from 7 commits
8103c52
a2354e2
b206ac3
95b34da
7888502
99706fd
62e5ccc
a70fc06
a4e21c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ type oidcState struct { | |
nonce string | ||
redirectURI string | ||
code string | ||
id_token string | ||
idToken string | ||
} | ||
|
||
func pathOIDC(b *jwtAuthBackend) []*framework.Path { | ||
|
@@ -115,7 +115,7 @@ func (b *jwtAuthBackend) pathCallbackPost(ctx context.Context, req *logical.Requ | |
|
||
stateID := d.Get("state").(string) | ||
code := d.Get("code").(string) | ||
id_token := d.Get("id_token").(string) | ||
idToken := d.Get("id_token").(string) | ||
|
||
resp := &logical.Response{ | ||
Data: map[string]interface{}{ | ||
|
@@ -125,7 +125,7 @@ func (b *jwtAuthBackend) pathCallbackPost(ctx context.Context, req *logical.Requ | |
} | ||
|
||
// Store the provided code and/or token into state, which must already exist. | ||
state, err := b.amendState(stateID, code, id_token) | ||
state, err := b.amendState(stateID, code, idToken) | ||
if err != nil { | ||
resp.Data[logical.HTTPRawBody] = []byte(errorHTML(errLoginFailed, "Expired or missing OAuth state.")) | ||
resp.Data[logical.HTTPStatusCode] = http.StatusBadRequest | ||
|
@@ -204,10 +204,10 @@ func (b *jwtAuthBackend) pathCallback(ctx context.Context, req *logical.Request, | |
} | ||
|
||
if code == "" { | ||
if state.id_token == "" { | ||
if state.idToken == "" { | ||
return logical.ErrorResponse(errLoginFailed + " No code or id_token received."), nil | ||
} | ||
rawToken = state.id_token | ||
rawToken = state.idToken | ||
} else { | ||
oauth2Token, err = oauth2Config.Exchange(oidcCtx, code) | ||
if err != nil { | ||
|
@@ -440,15 +440,15 @@ func (b *jwtAuthBackend) createState(rolename, redirectURI string) (string, stri | |
return stateID, nonce, nil | ||
} | ||
|
||
func (b *jwtAuthBackend) amendState(stateID, code, id_token string) (*oidcState, error) { | ||
func (b *jwtAuthBackend) amendState(stateID, code, idToken string) (*oidcState, error) { | ||
stateRaw, ok := b.oidcStates.Get(stateID) | ||
if !ok { | ||
return nil, errors.New("OIDC state not found") | ||
} | ||
|
||
state := stateRaw.(*oidcState) | ||
state.code = code | ||
state.id_token = id_token | ||
state.idToken = idToken | ||
|
||
b.oidcStates.SetDefault(stateID, state) | ||
|
||
|
@@ -502,12 +502,10 @@ func validRedirect(uri string, allowed []string) bool { | |
|
||
// parseMount attempts to extract the mount path from a redirect URI. | ||
func parseMount(redirectURI string) string { | ||
parts := strings.Split(redirectURI, "/") | ||
|
||
for i := 0; i+2 < len(parts); i++ { | ||
if parts[i] == "v1" && parts[i+1] == "auth" { | ||
return parts[i+2] | ||
} | ||
parts := strings.Split(redirectURI, "/v1/auth/") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually...it doesn't work and I restore the old code and revised the test. We only want the immediate next element, not the rest of the path. |
||
if len(parts) != 2 { | ||
// This doesn't look like an auth engine mount. | ||
return "" | ||
} | ||
return "" | ||
return parts[1] | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
The error that was here is the one that gets set on line 150.