Documentation ¶
Index ¶
- Constants
- Variables
- func Groups(ctx context.Context) []string
- func Iat(ctx context.Context) (time.Time, error)
- func Iss(ctx context.Context) string
- func LoggedIn(ctx context.Context) bool
- func NewInMemoryUserStateStorage() *inMemoryUserStateStorage
- func Sub(ctx context.Context) string
- func Username(ctx context.Context) string
- type LoginAttempts
- type SessionManager
- func (mgr *SessionManager) Create(subject string, secondsBeforeExpiry int64, id string) (string, error)
- func (mgr *SessionManager) GetLoginFailures() map[string]LoginAttempts
- func (mgr *SessionManager) Parse(tokenString string) (jwt.Claims, error)
- func (mgr *SessionManager) VerifyToken(tokenString string) (jwt.Claims, error)
- func (mgr *SessionManager) VerifyUsernamePassword(username string, password string) error
- type UserStateStorage
Constants ¶
const (
// SessionManagerClaimsIssuer fills the "iss" field of the token.
SessionManagerClaimsIssuer = "argocd"
)
Variables ¶
var (
InvalidLoginErr = status.Errorf(codes.Unauthenticated, invalidLoginError)
)
Functions ¶
func NewInMemoryUserStateStorage ¶ added in v1.5.3
func NewInMemoryUserStateStorage() *inMemoryUserStateStorage
Types ¶
type LoginAttempts ¶ added in v1.5.3
type LoginAttempts struct { // Time of the last failed login LastFailed time.Time `json:"lastFailed"` // Number of consecutive login failures FailCount int `json:"failCount"` }
LoginAttempts is a timestamped counter for failed login attempts
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager generates and validates JWT tokens for login sessions.
func NewSessionManager ¶ added in v0.4.0
func NewSessionManager(settingsMgr *settings.SettingsManager, dexServerAddr string, storage UserStateStorage) *SessionManager
NewSessionManager creates a new session manager from Argo CD settings
func (*SessionManager) Create ¶
func (mgr *SessionManager) Create(subject string, secondsBeforeExpiry int64, id string) (string, error)
Create creates a new token for a given subject (user) and returns it as a string. Passing a value of `0` for secondsBeforeExpiry creates a token that never expires. The id parameter holds an optional unique JWT token identifier and stored as a standard claim "jti" in the JWT token.
func (*SessionManager) GetLoginFailures ¶ added in v1.5.3
func (mgr *SessionManager) GetLoginFailures() map[string]LoginAttempts
GetLoginFailures retrieves the login failure information from the cache
func (*SessionManager) Parse ¶
func (mgr *SessionManager) Parse(tokenString string) (jwt.Claims, error)
Parse tries to parse the provided string and returns the token claims for local login.
func (*SessionManager) VerifyToken ¶ added in v0.4.0
func (mgr *SessionManager) VerifyToken(tokenString string) (jwt.Claims, error)
VerifyToken verifies if a token is correct. Tokens can be issued either from us or by an IDP. We choose how to verify based on the issuer.
func (*SessionManager) VerifyUsernamePassword ¶ added in v0.4.0
func (mgr *SessionManager) VerifyUsernamePassword(username string, password string) error
VerifyUsernamePassword verifies if a username/password combo is correct
type UserStateStorage ¶ added in v1.5.3
type UserStateStorage interface { GetLoginAttempts(attempts *map[string]LoginAttempts) error SetLoginAttempts(attempts map[string]LoginAttempts) error }