-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Split identity and user objects #1450
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,12 +22,13 @@ func NewDefaultConfig() *Config { | |
| } | ||
|
|
||
| type Authenticator struct { | ||
| config *Config | ||
| mapper authapi.UserIdentityMapper | ||
| providerName string | ||
| config *Config | ||
| mapper authapi.UserIdentityMapper | ||
| } | ||
|
|
||
| func NewAuthenticator(config *Config, mapper authapi.UserIdentityMapper) *Authenticator { | ||
| return &Authenticator{config, mapper} | ||
| func NewAuthenticator(providerName string, config *Config, mapper authapi.UserIdentityMapper) *Authenticator { | ||
| return &Authenticator{providerName, config, mapper} | ||
|
Contributor
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. providerName must not be empty. That's a global thing.
Contributor
Author
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. I'd rather catch that in config validation (future) and/or identity validation (which happens now) |
||
| } | ||
|
|
||
| func (a *Authenticator) AuthenticateRequest(req *http.Request) (user.Info, bool, error) { | ||
|
|
@@ -46,9 +47,7 @@ func (a *Authenticator) AuthenticateRequest(req *http.Request) (user.Info, bool, | |
| return nil, false, nil | ||
| } | ||
|
|
||
| identity := &authapi.DefaultUserIdentityInfo{ | ||
| UserName: username, | ||
| } | ||
| identity := authapi.NewDefaultUserIdentityInfo(a.providerName, username) | ||
| user, err := a.mapper.UserFor(identity) | ||
| if err != nil { | ||
| return nil, false, err | ||
|
|
||
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 isn't used how you'd expect.
GetProviderName()is never called. That suggests that this is the wrong abstractionThere 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.
Agree. Moved configurable providerName from the mapper into the various identity providers. I'm not sure why I didn't want to trust the identity providers to set the providerName on the identity info they give to the mapper