mirror of
https://github.com/1f349/lavender.git
synced 2025-04-14 06:55:55 +01:00
Rename StateExtended to StateAuthenticated
This commit is contained in:
parent
ba76dc5371
commit
159bc86d69
@ -12,17 +12,15 @@ const (
|
||||
// StateBasic defines the "username and password with no OTP" user state
|
||||
// This is skipped if OTP/passkey is optional and not enabled for the user
|
||||
StateBasic
|
||||
// StateExtended defines the "logged in" user state
|
||||
StateExtended
|
||||
// StateAuthenticated defines the "logged in" user state
|
||||
StateAuthenticated
|
||||
// StateSudo defines the "sudo" user state
|
||||
// This state is temporary and has a configurable duration
|
||||
StateSudo
|
||||
)
|
||||
|
||||
func (s State) IsValid() bool {
|
||||
return s <= StateSudo
|
||||
}
|
||||
func (s State) IsValid() bool { return s <= StateSudo }
|
||||
|
||||
func (s State) IsLoggedIn() bool { return s >= StateExtended }
|
||||
func (s State) IsLoggedIn() bool { return s >= StateAuthenticated }
|
||||
|
||||
func (s State) IsSudoAvailable() bool { return s == StateSudo }
|
||||
|
@ -175,7 +175,7 @@ func (o OAuthLogin) updateExternalUserInfo(req *http.Request, sso *issuer.WellKn
|
||||
})
|
||||
return auth.UserAuth{
|
||||
Subject: userSubject,
|
||||
Factor: process.StateExtended,
|
||||
Factor: process.StateBasic, // TODO: should the user be allowed to skip otp via oauth?
|
||||
UserInfo: sessionData.UserInfo,
|
||||
}, err
|
||||
case errors.Is(err, sql.ErrNoRows):
|
||||
@ -231,7 +231,7 @@ func (o OAuthLogin) updateExternalUserInfo(req *http.Request, sso *issuer.WellKn
|
||||
// TODO(melon): this feels bad
|
||||
sessionData = auth.UserAuth{
|
||||
Subject: userSubject,
|
||||
Factor: process.StateExtended,
|
||||
Factor: process.StateAuthenticated, // TODO: should the user be allowed to skip otp via oauth?
|
||||
UserInfo: sessionData.UserInfo,
|
||||
}
|
||||
|
||||
@ -296,7 +296,7 @@ func (o OAuthLogin) fetchUserInfo(sso *issuer.WellKnownOIDC, token *oauth2.Token
|
||||
|
||||
return auth.UserAuth{
|
||||
Subject: subject,
|
||||
Factor: process.StateExtended,
|
||||
Factor: process.StateBasic, // TODO: should the user be allowed to skip otp via oauth?
|
||||
UserInfo: userInfoJson,
|
||||
}, nil
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ func TestUserAuth_NextFlowUrl(t *testing.T) {
|
||||
assert.Equal(t, url.URL{Path: "/login"}, *u.NextFlowUrl(&url.URL{}))
|
||||
assert.Equal(t, url.URL{Path: "/login", RawQuery: url.Values{"redirect": {"/hello"}}.Encode()}, *u.NextFlowUrl(&url.URL{Path: "/hello"}))
|
||||
assert.Equal(t, url.URL{Path: "/login", RawQuery: url.Values{"redirect": {"/hello?a=A"}}.Encode()}, *u.NextFlowUrl(&url.URL{Path: "/hello", RawQuery: url.Values{"a": {"A"}}.Encode()}))
|
||||
u.Factor = process.StateExtended
|
||||
u.Factor = process.StateAuthenticated
|
||||
assert.Nil(t, u.NextFlowUrl(&url.URL{}))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user