Skip to content

Commit

Permalink
Merge pull request #15 from jmpsec/saml-login
Browse files Browse the repository at this point in the history
Redirect to SAML login
  • Loading branch information
javuto authored Sep 26, 2019
2 parents 9eef5f5 + d6169f3 commit 0e147fd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cmd/admin/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ func handlerAuthCheck(h http.Handler) http.Handler {
cookiev, err := r.Cookie(samlConfig.TokenName)
if err != nil {
log.Printf("error extracting JWT data: %v", err)
http.Redirect(w, r, forbiddenPath, http.StatusFound)
http.Redirect(w, r, samlConfig.LoginURL, http.StatusFound)
return
}
jwtdata, err := parseJWTFromCookie(samlData.KeyPair, cookiev.Value)
if err != nil {
log.Printf("error parsing JWT: %v", err)
http.Redirect(w, r, forbiddenPath, http.StatusFound)
http.Redirect(w, r, samlConfig.LoginURL, http.StatusFound)
return
}
// Check if user is already authenticated
Expand All @@ -79,6 +79,8 @@ func handlerAuthCheck(h http.Handler) http.Handler {
session, err = sessionsmgr.Save(r, w, u)
if err != nil {
log.Printf("session error: %v", err)
http.Redirect(w, r, samlConfig.LoginURL, http.StatusFound)
return
}
}
// Update metadata for the user
Expand Down
1 change: 1 addition & 0 deletions cmd/admin/saml.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type JSONConfigurationSAML struct {
KeyPath string `json:"keypath"`
MetaDataURL string `json:"metadataurl"`
RootURL string `json:"rooturl"`
LoginURL string `json:"loginurl"`
TokenName string `json:"nametoken"`
EmailAttr string `json:"attremail"`
UserAttr string `json:"attruser"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/admin/static/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

.img-logo {
max-width: 100%;
height: auto;
height: 20em;
object-fit: cover;
}

Expand Down

0 comments on commit 0e147fd

Please sign in to comment.