Documentation ¶
Index ¶
- Constants
- func AdminRequiredMiddleware(next http.Handler) http.Handler
- func Expires(ctx context.Context) *time.Time
- func FullName(ctx context.Context) string
- func GetAdminContext(ctx context.Context) context.Context
- func InstanceEntity(ctx context.Context) string
- func InstanceHasJITConfig(ctx context.Context) bool
- func InstanceID(ctx context.Context) string
- func InstanceName(ctx context.Context) string
- func InstanceParams(ctx context.Context) (params.Instance, error)
- func InstancePoolID(ctx context.Context) string
- func InstancePoolType(ctx context.Context) string
- func InstanceRunnerStatus(ctx context.Context) params.RunnerStatus
- func InstanceTokenFetched(ctx context.Context) bool
- func IsAdmin(ctx context.Context) bool
- func IsEnabled(ctx context.Context) bool
- func PasswordGeneration(ctx context.Context) uint
- func PopulateContext(ctx context.Context, user params.User, authExpires *time.Time) context.Context
- func PopulateInstanceContext(ctx context.Context, instance params.Instance) context.Context
- func SetAdmin(ctx context.Context, isAdmin bool) context.Context
- func SetExpires(ctx context.Context, expires *time.Time) context.Context
- func SetFullName(ctx context.Context, fullName string) context.Context
- func SetInstanceEntity(ctx context.Context, val string) context.Context
- func SetInstanceHasJITConfig(ctx context.Context, cfg map[string]string) context.Context
- func SetInstanceID(ctx context.Context, id string) context.Context
- func SetInstanceName(ctx context.Context, val string) context.Context
- func SetInstanceParams(ctx context.Context, instance params.Instance) context.Context
- func SetInstancePoolID(ctx context.Context, val string) context.Context
- func SetInstancePoolType(ctx context.Context, val string) context.Context
- func SetInstanceRunnerStatus(ctx context.Context, val params.RunnerStatus) context.Context
- func SetInstanceTokenFetched(ctx context.Context, fetched bool) context.Context
- func SetIsEnabled(ctx context.Context, enabled bool) context.Context
- func SetPasswordGeneration(ctx context.Context, val uint) context.Context
- func SetUserID(ctx context.Context, userID string) context.Context
- func UserID(ctx context.Context) string
- type Authenticator
- func (a *Authenticator) AuthenticateUser(ctx context.Context, info params.PasswordLoginParams) (context.Context, error)
- func (a *Authenticator) GetJWTMetricsToken(ctx context.Context) (string, error)
- func (a *Authenticator) GetJWTToken(ctx context.Context) (string, error)
- func (a *Authenticator) InitController(ctx context.Context, param params.NewUserParams) (params.User, error)
- func (a *Authenticator) IsInitialized() bool
- type InstanceJWTClaims
- type InstanceTokenGetter
- type JWTClaims
- type MetricsMiddleware
- type Middleware
- func NewInitRequiredMiddleware(store common.Store) (Middleware, error)
- func NewInstanceMiddleware(store dbCommon.Store, cfg config.JWTAuth) (Middleware, error)
- func NewUrlsRequiredMiddleware(store common.Store) (Middleware, error)
- func NewjwtMiddleware(store dbCommon.Store, cfg config.JWTAuth) (Middleware, error)
Constants ¶
const (
// UserIDFlag is the User ID flag we set in the context
UserIDFlag contextFlags = "user_id"
)
Variables ¶
This section is empty.
Functions ¶
func AdminRequiredMiddleware ¶ added in v0.1.4
func GetAdminContext ¶
GetAdminContext will return an admin context. This can be used internally when fetching users.
func InstanceEntity ¶
func InstanceHasJITConfig ¶ added in v0.1.4
func InstanceID ¶
func InstanceName ¶
func InstanceParams ¶ added in v0.1.4
func InstancePoolID ¶
func InstancePoolType ¶
func InstanceRunnerStatus ¶
func InstanceRunnerStatus(ctx context.Context) params.RunnerStatus
func InstanceTokenFetched ¶
func IsAdmin ¶
IsAdmin returns a boolean indicating whether or not the context belongs to a logged in user and if that context has the admin flag set
func IsEnabled ¶
IsEnabled returns the a boolean indicating if the enabled flag is set and is true or false
func PasswordGeneration ¶ added in v0.1.5
func PopulateContext ¶
PopulateContext sets the appropriate fields in the context, based on the user object
func PopulateInstanceContext ¶
func SetExpires ¶ added in v0.1.5
func SetFullName ¶
SetFullName sets the user full name in the context
func SetInstanceHasJITConfig ¶ added in v0.1.4
func SetInstanceParams ¶ added in v0.1.4
func SetInstancePoolType ¶
func SetInstanceRunnerStatus ¶
func SetInstanceTokenFetched ¶
func SetIsEnabled ¶
SetIsEnabled sets a flag indicating if account is enabled
func SetPasswordGeneration ¶ added in v0.1.5
Types ¶
type Authenticator ¶
type Authenticator struct {
// contains filtered or unexported fields
}
func NewAuthenticator ¶
func NewAuthenticator(cfg config.JWTAuth, store common.Store) *Authenticator
func (*Authenticator) AuthenticateUser ¶
func (a *Authenticator) AuthenticateUser(ctx context.Context, info params.PasswordLoginParams) (context.Context, error)
func (*Authenticator) GetJWTMetricsToken ¶
func (a *Authenticator) GetJWTMetricsToken(ctx context.Context) (string, error)
GetJWTMetricsToken returns a JWT token that can be used to read metrics. This token is not tied to a user, no user is stored in the db.
func (*Authenticator) GetJWTToken ¶
func (a *Authenticator) GetJWTToken(ctx context.Context) (string, error)
func (*Authenticator) InitController ¶
func (a *Authenticator) InitController(ctx context.Context, param params.NewUserParams) (params.User, error)
func (*Authenticator) IsInitialized ¶
func (a *Authenticator) IsInitialized() bool
type InstanceJWTClaims ¶
type InstanceJWTClaims struct { ID string `json:"id"` Name string `json:"name"` PoolID string `json:"provider_id"` // Scope is either repository or organization Scope params.GithubEntityType `json:"scope"` // Entity is the repo or org name Entity string `json:"entity"` CreateAttempt int `json:"create_attempt"` jwt.RegisteredClaims }
InstanceJWTClaims holds JWT claims
type InstanceTokenGetter ¶ added in v0.1.5
type InstanceTokenGetter interface {
NewInstanceJWTToken(instance params.Instance, entity string, poolType params.GithubEntityType, ttlMinutes uint) (string, error)
}
func NewInstanceTokenGetter ¶ added in v0.1.5
func NewInstanceTokenGetter(jwtSecret string) (InstanceTokenGetter, error)
type JWTClaims ¶
type JWTClaims struct { UserID string `json:"user"` TokenID string `json:"token_id"` FullName string `json:"full_name"` IsAdmin bool `json:"is_admin"` ReadMetrics bool `json:"read_metrics"` Generation uint `json:"generation"` jwt.RegisteredClaims }
JWTClaims holds JWT claims
type MetricsMiddleware ¶
type MetricsMiddleware struct {
// contains filtered or unexported fields
}
func NewMetricsMiddleware ¶
func NewMetricsMiddleware(cfg config.JWTAuth) (*MetricsMiddleware, error)
func (*MetricsMiddleware) Middleware ¶
func (m *MetricsMiddleware) Middleware(next http.Handler) http.Handler
type Middleware ¶
Middleware defines an authentication middleware
func NewInitRequiredMiddleware ¶
func NewInitRequiredMiddleware(store common.Store) (Middleware, error)
NewjwtMiddleware returns a populated jwtMiddleware
func NewInstanceMiddleware ¶
NewjwtMiddleware returns a populated jwtMiddleware
func NewUrlsRequiredMiddleware ¶ added in v0.1.5
func NewUrlsRequiredMiddleware(store common.Store) (Middleware, error)
func NewjwtMiddleware ¶
NewjwtMiddleware returns a populated jwtMiddleware