mirror of
https://github.com/goauthentik/authentik
synced 2026-04-27 09:57:31 +02:00
* re-instate previously flaky test Signed-off-by: Jens Langhammer <jens@goauthentik.io> * break up big file Signed-off-by: Jens Langhammer <jens@goauthentik.io> * move geoip data to subdir Signed-off-by: Jens Langhammer <jens@goauthentik.io> * i am but a weak man Signed-off-by: Jens Langhammer <jens@goauthentik.io> * fix ldap disconnect in testing Signed-off-by: Jens Langhammer <jens@goauthentik.io> * account for mismatched uid due to test server process Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: Jens Langhammer <jens@goauthentik.io>
29 lines
620 B
Go
29 lines
620 B
Go
package flow
|
|
|
|
import "github.com/golang-jwt/jwt/v5"
|
|
|
|
type SessionCookieClaims struct {
|
|
jwt.Claims
|
|
|
|
SessionID string `json:"sid"`
|
|
Authenticated bool `json:"authenticated"`
|
|
}
|
|
|
|
func (fe *FlowExecutor) Session() *jwt.Token {
|
|
sc := fe.SessionCookie()
|
|
if sc == nil {
|
|
return nil
|
|
}
|
|
t, _, _ := jwt.NewParser().ParseUnverified(sc.Value, &SessionCookieClaims{})
|
|
// During testing the session cookie value is not a JWT but rather just the session ID
|
|
// in which case we wrap that in a pseudo-JWT
|
|
if t == nil {
|
|
return &jwt.Token{
|
|
Claims: &SessionCookieClaims{
|
|
SessionID: sc.Value,
|
|
},
|
|
}
|
|
}
|
|
return t
|
|
}
|