Documentation ¶
Index ¶
- func GetAPIKey(ctx context.Context) ([]byte, bool)
- func WithAPIKey(ctx context.Context, key []byte) context.Context
- type Claims
- type Config
- type Hmac
- type OrderDirection
- type Service
- type Signer
- type Token
- type WebappSession
- type WebappSessions
- type WebappSessionsCursor
- type WebappSessionsOrder
- type WebappSessionsPage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Claims ¶
type Claims struct { ID uuid.UUID `json:"id"` Email string `json:"email,omitempty"` Expiration time.Time `json:"expires,omitempty"` }
Claims represents data signed by server and used for authentication.
type Config ¶ added in v1.56.1
type Config struct {
TokenExpirationTime time.Duration `help:"expiration time for account recovery and activation tokens" default:"30m"`
}
Config contains configuration parameters for console auth.
type OrderDirection ¶ added in v1.111.4
type OrderDirection uint8
OrderDirection is used for members in specific order direction.
const ( // Ascending indicates that we should order ascending. Ascending OrderDirection = 1 // Descending indicates that we should order descending. Descending OrderDirection = 2 )
type Service ¶ added in v1.56.1
type Service struct { Signer // contains filtered or unexported fields }
Service handles creating, signing, and checking the expiration of auth tokens.
func NewService ¶ added in v1.56.1
NewService creates a new consoleauth service.
func (*Service) CreateToken ¶ added in v1.56.1
func (s *Service) CreateToken(ctx context.Context, id uuid.UUID, email string) (_ string, err error)
CreateToken creates a new auth token.
type Token ¶
Token represents authentication data structure.
func FromBase64URLString ¶
FromBase64URLString creates Token instance from base64URLEncoded string representation.
type WebappSession ¶ added in v1.56.1
type WebappSession struct { ID uuid.UUID `json:"id"` UserID uuid.UUID `json:"-"` Address string `json:"-"` UserAgent string `json:"userAgent"` Status int `json:"-"` ExpiresAt time.Time `json:"expiresAt"` IsRequesterCurrentSession bool `json:"isRequesterCurrentSession"` }
WebappSession represents a session on the satellite web app.
type WebappSessions ¶ added in v1.56.1
type WebappSessions interface { // Create creates a webapp session and returns the session info. Create(ctx context.Context, id, userID uuid.UUID, ip, userAgent string, expires time.Time) (WebappSession, error) // GetBySessionID gets the session info from the session ID. GetBySessionID(ctx context.Context, sessionID uuid.UUID) (WebappSession, error) // GetAllByUserID gets all webapp sessions with userID. GetAllByUserID(ctx context.Context, userID uuid.UUID) ([]WebappSession, error) // GetPagedActiveByUserID gets all active webapp sessions by userID, offset and limit. GetPagedActiveByUserID(ctx context.Context, userID uuid.UUID, expiresAt time.Time, cursor WebappSessionsCursor) (*WebappSessionsPage, error) // DeleteBySessionID deletes a webapp session by ID. DeleteBySessionID(ctx context.Context, sessionID uuid.UUID) error // DeleteAllByUserID deletes all webapp sessions by user ID. DeleteAllByUserID(ctx context.Context, userID uuid.UUID) (int64, error) // DeleteAllByUserIDExcept deletes all webapp sessions by user ID except one of sessionID. DeleteAllByUserIDExcept(ctx context.Context, userID uuid.UUID, sessionID uuid.UUID) (int64, error) // UpdateExpiration updates the expiration time of the session. UpdateExpiration(ctx context.Context, sessionID uuid.UUID, expiresAt time.Time) error // DeleteExpired deletes all sessions that have expired before the provided timestamp. DeleteExpired(ctx context.Context, now time.Time, asOfSystemTimeInterval time.Duration, pageSize int) error }
WebappSessions is the repository for webapp sessions.
type WebappSessionsCursor ¶ added in v1.111.4
type WebappSessionsCursor struct { Limit uint Page uint Order WebappSessionsOrder OrderDirection OrderDirection }
WebappSessionsCursor holds info for webapp sessions cursor pagination.
type WebappSessionsOrder ¶ added in v1.111.4
type WebappSessionsOrder int8
WebappSessionsOrder is used for querying webapp sessions in specified order.
const ( // UserAgent indicates that we should order by user agent. UserAgent WebappSessionsOrder = 1 // ExpiresAt indicates that we should order by expiration date. ExpiresAt WebappSessionsOrder = 2 )
type WebappSessionsPage ¶ added in v1.111.4
type WebappSessionsPage struct { Sessions []WebappSession `json:"sessions"` Limit uint `json:"limit"` Order WebappSessionsOrder `json:"order"` OrderDirection OrderDirection `json:"orderDirection"` Offset uint64 `json:"offset"` PageCount uint `json:"pageCount"` CurrentPage uint `json:"currentPage"` TotalCount uint64 `json:"totalCount"` }
WebappSessionsPage represents a page of webapp sessions.