Documentation ¶
Index ¶
- Variables
- type AccessToken
- type AccessTokenType
- type AuthService
- type Backend
- type Core
- type CreateSessionOptions
- type CreateTokenOptions
- type RegisterOptions
- type ResponseTokenClaims
- type SessionsService
- type TerminateSessionOptions
- type TokenClaims
- type TokenFromCredentialsOptions
- type TokenFromProviderOptions
- type TokenResult
- type Users
- type UsersService
Constants ¶
This section is empty.
Variables ¶
var ( // ErrAuthInvalidCredentials is returned when the credentials provided are invalid. ErrAuthInvalidCredentials = errors.New("credentials provided are not valid") // ErrAuthPasswordNotSet is returned when a User attempts to authenticate with a password but // has not yet set a password (such as when creating their account with a provider). ErrAuthPasswordNotSet = errors.New("password is not set") // ErrAuthEmailAlreadyRegistered is returned when a User attempts to register with an email address // that is already in-use. ErrAuthEmailAlreadyRegistered = errors.New("email already registered") )
var ( // ErrSessionsSessionDoesNotExist is returned when a session being terminates does not // exist. ErrSessionsSessionDoesNotExist = errors.New("session does not exist") )
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶
type AccessToken struct { Type AccessTokenType Data *ent.Token // contains filtered or unexported fields }
AccessToken is an access token for User and Bot access.
func (*AccessToken) String ¶
func (a *AccessToken) String() (string, error)
type AccessTokenType ¶
type AccessTokenType int
AccessTokenType represents the type of object an AccessToken is issued to.
const ( // UserAccessTokenType represents an AccessToken issued to a User. UserAccessTokenType AccessTokenType = iota + 1 // BotAccessTokenType represents an AccessToken issued to a Bot. BotAccessTokenType )
type AuthService ¶
type AuthService interface { // TokenFromCredentials returns a token given valid credentials or an error if the credetnails are invalid. TokenFromCredentials(ctx context.Context, opts *TokenFromCredentialsOptions) (*TokenResult, error) // TokenFromProvider returns a token given valid provider credentials or an error if the credetnails are invalid. TokenFromProvider(ctx context.Context, opts *TokenFromProviderOptions) (*TokenResult, error) // Register is called when registering a User. Register(ctx context.Context, opts *RegisterOptions) (*ent.User, error) }
AuthService handles user authentication.
type Backend ¶
type Backend interface { Database() *database.Database Events() events.PubSub Cluster() cluster.Cluster }
Backend describes the methods requires to properly initialize Core.
type Core ¶
type Core struct { Auth AuthService Users UsersService Sessions SessionsService // contains filtered or unexported fields }
Core is a wrapper around database and application logic, queries, and event subscribers.
type CreateSessionOptions ¶
type CreateSessionOptions struct { UserID int BrowserName string BrowserVersion string DeviceType string DeviceOperatingSystem string IPAddress string }
CreateSessionOptions configures the CreateSession method.
type CreateTokenOptions ¶
type CreateTokenOptions struct { SessionID int UserID int TokenDuration time.Duration Claims *TokenClaims }
CreateTokenOptions configures the CreateToken
type RegisterOptions ¶
RegisterOptions configures the registration of a User.
type ResponseTokenClaims ¶
type ResponseTokenClaims struct {
Name string
}
ResponseTokenClaims contains the Response-specific claims stored in JWT's.
type SessionsService ¶
type SessionsService interface { GetSession(ctx context.Context, id int) (*ent.Session, error) CreateSession(ctx context.Context, opts *CreateSessionOptions) (*ent.Session, error) TerminateSession(ctx context.Context, opts *TerminateSessionOptions) error }
SessionsService allows managing sessions in Response.
type TerminateSessionOptions ¶
TerminateSessionOptions configures the TerminateSession method.
type TokenClaims ¶
type TokenClaims struct { jwt.StandardClaims Response ResponseTokenClaims }
TokenClaims are the standard and Respnose-specific claims stored in JWT's.
type TokenFromCredentialsOptions ¶
type TokenFromCredentialsOptions struct { Email string Password string BrowserName string BrowserVersion string DeviceType string DeviceOperatingSystem string IPAddress string }
TokenFromCredentialsOptions configures the TokenFromCredentials method.
type TokenFromProviderOptions ¶
TokenFromProviderOptions configures the TokenFromProvider method.
type TokenResult ¶
type TokenResult struct { Token *AccessToken ExpiredAt time.Time }
TokenResult provides a token when the token has been succcessfully created from an authentication attempt.