mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2025-05-31 23:19:50 +02:00
Merge pull request #791 from grnhse/remove-provider-preferred-username-getter
Remove provider GetPreferredUsername getter method
This commit is contained in:
commit
e9aa7acf4e
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
- [#575](https://github.com/oauth2-proxy/oauth2-proxy/pull/575) Stop accepting legacy SHA1 signed cookies (@NickMeves)
|
- [#575](https://github.com/oauth2-proxy/oauth2-proxy/pull/575) Stop accepting legacy SHA1 signed cookies (@NickMeves)
|
||||||
- [#722](https://github.com/oauth2-proxy/oauth2-proxy/pull/722) Validate Redis configuration options at startup (@NickMeves)
|
- [#722](https://github.com/oauth2-proxy/oauth2-proxy/pull/722) Validate Redis configuration options at startup (@NickMeves)
|
||||||
|
- [#791](https://github.com/oauth2-proxy/oauth2-proxy/pull/791) Remove GetPreferredUsername method from provider interface (@NickMeves)
|
||||||
- [#764](https://github.com/oauth2-proxy/oauth2-proxy/pull/764) Document bcrypt encryption for htpasswd (and hide SHA) (@lentzi90)
|
- [#764](https://github.com/oauth2-proxy/oauth2-proxy/pull/764) Document bcrypt encryption for htpasswd (and hide SHA) (@lentzi90)
|
||||||
- [#616](https://github.com/oauth2-proxy/oauth2-proxy/pull/616) Add support to ensure user belongs in required groups when using the OIDC provider (@stefansedich)
|
- [#616](https://github.com/oauth2-proxy/oauth2-proxy/pull/616) Add support to ensure user belongs in required groups when using the OIDC provider (@stefansedich)
|
||||||
|
|
||||||
|
@ -296,34 +296,31 @@ func (p *OAuthProxy) GetRedirectURI(host string) string {
|
|||||||
return u.String()
|
return u.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *OAuthProxy) redeemCode(ctx context.Context, host, code string) (s *sessionsapi.SessionState, err error) {
|
func (p *OAuthProxy) redeemCode(ctx context.Context, host, code string) (*sessionsapi.SessionState, error) {
|
||||||
if code == "" {
|
if code == "" {
|
||||||
return nil, errors.New("missing code")
|
return nil, errors.New("missing code")
|
||||||
}
|
}
|
||||||
redirectURI := p.GetRedirectURI(host)
|
redirectURI := p.GetRedirectURI(host)
|
||||||
s, err = p.provider.Redeem(ctx, redirectURI, code)
|
s, err := p.provider.Redeem(ctx, redirectURI, code)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.Email == "" {
|
if s.Email == "" {
|
||||||
s.Email, err = p.provider.GetEmailAddress(ctx, s)
|
s.Email, err = p.provider.GetEmailAddress(ctx, s)
|
||||||
}
|
if err != nil && err.Error() != "not implemented" {
|
||||||
|
return nil, err
|
||||||
if s.PreferredUsername == "" {
|
|
||||||
s.PreferredUsername, err = p.provider.GetPreferredUsername(ctx, s)
|
|
||||||
if err != nil && err.Error() == "not implemented" {
|
|
||||||
err = nil
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.User == "" {
|
if s.User == "" {
|
||||||
s.User, err = p.provider.GetUserName(ctx, s)
|
s.User, err = p.provider.GetUserName(ctx, s)
|
||||||
if err != nil && err.Error() == "not implemented" {
|
if err != nil && err.Error() != "not implemented" {
|
||||||
err = nil
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MakeCSRFCookie creates a cookie for CSRF
|
// MakeCSRFCookie creates a cookie for CSRF
|
||||||
|
@ -104,11 +104,6 @@ func (p *ProviderData) GetUserName(ctx context.Context, s *sessions.SessionState
|
|||||||
return "", errors.New("not implemented")
|
return "", errors.New("not implemented")
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetPreferredUsername returns the Account preferred username
|
|
||||||
func (p *ProviderData) GetPreferredUsername(ctx context.Context, s *sessions.SessionState) (string, error) {
|
|
||||||
return "", errors.New("not implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
// ValidateGroup validates that the provided email exists in the configured provider
|
// ValidateGroup validates that the provided email exists in the configured provider
|
||||||
// email group(s).
|
// email group(s).
|
||||||
func (p *ProviderData) ValidateGroup(email string) bool {
|
func (p *ProviderData) ValidateGroup(email string) bool {
|
||||||
|
@ -12,7 +12,6 @@ type Provider interface {
|
|||||||
Data() *ProviderData
|
Data() *ProviderData
|
||||||
GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error)
|
GetEmailAddress(ctx context.Context, s *sessions.SessionState) (string, error)
|
||||||
GetUserName(ctx context.Context, s *sessions.SessionState) (string, error)
|
GetUserName(ctx context.Context, s *sessions.SessionState) (string, error)
|
||||||
GetPreferredUsername(ctx context.Context, s *sessions.SessionState) (string, error)
|
|
||||||
Redeem(ctx context.Context, redirectURI, code string) (*sessions.SessionState, error)
|
Redeem(ctx context.Context, redirectURI, code string) (*sessions.SessionState, error)
|
||||||
ValidateGroup(string) bool
|
ValidateGroup(string) bool
|
||||||
ValidateSessionState(ctx context.Context, s *sessions.SessionState) bool
|
ValidateSessionState(ctx context.Context, s *sessions.SessionState) bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user