mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-18 04:47:28 +00:00
Add logout URL to the invalid authentication email.
This is to prevent deadlock when user has logged in with wrong email address.
This commit is contained in:
@@ -165,11 +165,16 @@ func New(ctx context.Context, next http.Handler, config *Config, name string) (h
|
|||||||
}
|
}
|
||||||
|
|
||||||
t := &TraefikOidc{
|
t := &TraefikOidc{
|
||||||
next: next,
|
next: next,
|
||||||
name: name,
|
name: name,
|
||||||
store: store,
|
store: store,
|
||||||
redirURLPath: config.CallbackURL,
|
redirURLPath: config.CallbackURL,
|
||||||
logoutURLPath: config.LogoutURL,
|
logoutURLPath: func() string {
|
||||||
|
if config.LogoutURL == "" {
|
||||||
|
return config.CallbackURL + "/logout"
|
||||||
|
}
|
||||||
|
return config.LogoutURL
|
||||||
|
}(),
|
||||||
issuerURL: metadata.Issuer,
|
issuerURL: metadata.Issuer,
|
||||||
tokenBlacklist: NewTokenBlacklist(),
|
tokenBlacklist: NewTokenBlacklist(),
|
||||||
jwkCache: &JWKCache{},
|
jwkCache: &JWKCache{},
|
||||||
@@ -313,14 +318,14 @@ func (t *TraefikOidc) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
|||||||
|
|
||||||
email, _ := claims["email"].(string)
|
email, _ := claims["email"].(string)
|
||||||
if email == "" {
|
if email == "" {
|
||||||
t.logger.Errorf("No email found in token claims")
|
t.logger.Debugf("No email found in token claims")
|
||||||
t.initiateAuthentication(rw, req, session, t.redirectURL)
|
t.initiateAuthentication(rw, req, session, t.redirectURL)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !t.isAllowedDomain(email) {
|
if !t.isAllowedDomain(email) {
|
||||||
t.logger.Infof("User with email %s is not from an allowed domain", email)
|
t.logger.Infof("User with email %s is not from an allowed domain", email)
|
||||||
http.Error(rw, "Access denied: Your email domain is not allowed", http.StatusForbidden)
|
http.Error(rw, fmt.Sprintf("Access denied: Your email domain is not allowed. <a href=\"%s\">Log me out</a>", t.logoutURLPath), http.StatusForbidden)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user