Skip to content

Commit 00e0c65

Browse files
praneetlokecrewjam
authored andcommitted
Prevent panic caused by IDP-initiated login (crewjam#183)
* - Check if IDP-initiated login is allowed and if so assume that the RelayState is a deep-link. - Guard against an IDP-initiated request that may not have the request ID in the claims. - Attempt to retrieve a state value using the RelayState first before checking if IDP-initiated flow is allowed. * Only address the panic in IDP-initiated login (#1) This change undoes some of the changes made in 4908b26, to just address the panic for IDP-initiated logins. I'll file an issue in the `crewjam/saml` repo about the other issue blocking IDP-initiated logins, which is how to support relay states from the IDP.
1 parent ee7c957 commit 00e0c65

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

samlsp/middleware.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ func (m *Middleware) getPossibleRequestIDs(r *http.Request) []string {
186186
m.ServiceProvider.Logger.Printf("... invalid token %s", err)
187187
continue
188188
}
189+
// If IDP initiated requests are allowed, then we can expect an empty response ID.
189190
claims := token.Claims.(jwt.MapClaims)
190-
rv = append(rv, claims["id"].(string))
191+
if id, ok := claims["id"]; ok {
192+
rv = append(rv, id.(string))
193+
}
191194
}
192195

193-
// If IDP initiated requests are allowed, then we can expect an empty response ID.
194196
if m.AllowIDPInitiated {
195197
rv = append(rv, "")
196198
}

0 commit comments

Comments
 (0)