Documentation ¶
Index ¶
- type APIController
- type DefaultAPIController
- func (cntrl *DefaultAPIController) AuthClientRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) AuthorizationRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) CreateClientRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) DB() authdb.Database
- func (cntrl *DefaultAPIController) DeleteClientRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) GetClientRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) GetClientsRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) GetUserRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) GetUsersRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) ResetPwdRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) SignInRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) SignUpRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) Stop() error
- func (cntrl *DefaultAPIController) TokenRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) UpdateUserRoute() gin.HandlerFunc
- func (cntrl *DefaultAPIController) VerifyEmailRoute() gin.HandlerFunc
- type MailSender
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIController ¶
type APIController interface { SignUpRoute() gin.HandlerFunc SignInRoute() gin.HandlerFunc VerifyEmailRoute() gin.HandlerFunc AuthClientRoute() gin.HandlerFunc AuthorizationRoute() gin.HandlerFunc TokenRoute() gin.HandlerFunc GetUserRoute() gin.HandlerFunc UpdateUserRoute() gin.HandlerFunc GetUsersRoute() gin.HandlerFunc ResetPwdRoute() gin.HandlerFunc GetClientRoute() gin.HandlerFunc CreateClientRoute() gin.HandlerFunc DeleteClientRoute() gin.HandlerFunc GetClientsRoute() gin.HandlerFunc DB() authdb.Database Stop() error }
APIController is an interface for retrieving gin middleware for each route in the authorization server.
func CreateAPIController ¶
func CreateAPIController(uri, name, addr, secret string) (APIController, error)
CreateAPIController creates an instance of APIController using uri and name as the MongoDB connection string and database name, respectively. addr is the email address to send verification emails from. secret is the random string for signing JWTs.
type DefaultAPIController ¶
type DefaultAPIController struct {
// contains filtered or unexported fields
}
DefaultAPIController implements APIController using authdb.
func (*DefaultAPIController) AuthClientRoute ¶
func (cntrl *DefaultAPIController) AuthClientRoute() gin.HandlerFunc
AuthClientRoute authenticates a client and issues a client JWT.
func (*DefaultAPIController) AuthorizationRoute ¶
func (cntrl *DefaultAPIController) AuthorizationRoute() gin.HandlerFunc
AuthorizationRoute returns the middleware for the Oauth2 authorize route.
func (*DefaultAPIController) CreateClientRoute ¶
func (cntrl *DefaultAPIController) CreateClientRoute() gin.HandlerFunc
CreateCreateClient returns the gin middleware for registering a new client. It expects user authentication (clients are owned by users).
func (*DefaultAPIController) DB ¶
func (cntrl *DefaultAPIController) DB() authdb.Database
DB returns the underlying database interface.
func (*DefaultAPIController) DeleteClientRoute ¶
func (cntrl *DefaultAPIController) DeleteClientRoute() gin.HandlerFunc
DeleteClientRoute returns the gin middleware for deleting a client.
func (*DefaultAPIController) GetClientRoute ¶
func (cntrl *DefaultAPIController) GetClientRoute() gin.HandlerFunc
GetClientRoute returns public information about a client.
func (*DefaultAPIController) GetClientsRoute ¶
func (cntrl *DefaultAPIController) GetClientsRoute() gin.HandlerFunc
GetClientsRoute returns the batch of 20 clients determined by the page URL parameter.
func (*DefaultAPIController) GetUserRoute ¶
func (cntrl *DefaultAPIController) GetUserRoute() gin.HandlerFunc
GetUserRoute returns user information based on the permissions defined by the client's scope.
func (*DefaultAPIController) GetUsersRoute ¶
func (cntrl *DefaultAPIController) GetUsersRoute() gin.HandlerFunc
GetUsersRoute returns the batch of 20 users determined by the page URL parameter.
func (*DefaultAPIController) ResetPwdRoute ¶
func (cntrl *DefaultAPIController) ResetPwdRoute() gin.HandlerFunc
ForgotPassword sends the user an email to change their password.
func (*DefaultAPIController) SignInRoute ¶
func (cntrl *DefaultAPIController) SignInRoute() gin.HandlerFunc
SignInRoute authenticates a user and issues a JWT.
func (*DefaultAPIController) SignUpRoute ¶
func (cntrl *DefaultAPIController) SignUpRoute() gin.HandlerFunc
SignUpRoute creates a new pending user and sends an email verification request.
func (*DefaultAPIController) Stop ¶
func (cntrl *DefaultAPIController) Stop() error
Stop the underlying database.
func (*DefaultAPIController) TokenRoute ¶
func (cntrl *DefaultAPIController) TokenRoute() gin.HandlerFunc
TokenRoute returns the gin middleware for the Oauth2 token route.
func (*DefaultAPIController) UpdateUserRoute ¶
func (cntrl *DefaultAPIController) UpdateUserRoute() gin.HandlerFunc
UpdateUserRoute updates user information.
func (*DefaultAPIController) VerifyEmailRoute ¶
func (cntrl *DefaultAPIController) VerifyEmailRoute() gin.HandlerFunc
VerifyEmailRoute consumes an email verification reference.
type MailSender ¶
type MailSender struct {
// contains filtered or unexported fields
}
MailSender encapsulates a websmtp.Sender object.
func NewMailSender ¶
func NewMailSender(addr string) MailSender
NewMailSender creates a new MailSender with the given config.
func (MailSender) SendVerification ¶
func (ms MailSender) SendVerification(id, email string) bool
SendVerification sends the signup verification email, where id is the MongoDB object ID of the pending user and email is their email address.
func (MailSender) Start ¶
func (ms MailSender) Start(n int) error
Start the mail sender project with 'n' threads.