117 lines
3.1 KiB
Go
117 lines
3.1 KiB
Go
package auth
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/volatiletech/authboss/v3"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
)
|
|
|
|
/*
|
|
MongoStorer is a MongoDB-based implementation of an authboss.ServerStorer.
|
|
*/
|
|
type MongoStorer struct {
|
|
db *mongo.Client
|
|
}
|
|
|
|
/*
|
|
AddRememberToken adds a remember token for a pid to a user, as part of the
|
|
authboss.RememberingServerStorer interface.
|
|
*/
|
|
func (s *MongoStorer) AddRememberToken(ctx context.Context, pid, token string) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
Create creates a new user in storage if it does not already exist, as part of
|
|
the authboss.CreatingServerStorer interface.
|
|
|
|
If the user already exists, it returns authboss.ErrUserFound instead.
|
|
*/
|
|
func (s *MongoStorer) Create(ctx context.Context, user authboss.User) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
DelRememberTokens removes all remember tokens for the given pid from a user,
|
|
as part of the authboss.RememberingServerStorer interface.
|
|
*/
|
|
func (s *MongoStorer) DelRememberTokens(ctx context.Context, pid string) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
Load loads a user by its primary id, usually its Pid except for OAuth 2, as part
|
|
of the authboss.ServerStorer interface.
|
|
*/
|
|
func (s *MongoStorer) Load(ctx context.Context, key string) (authboss.User, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
LoadByConfirmSelector loads a user by a confirm selector, as part of the
|
|
authboss.ConfirmingServerStorer interface.
|
|
*/
|
|
func (s *MongoStorer) LoadByConfirmSelector(ctx context.Context, selector string) (authboss.ConfirmableUser, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
LoadByRecoverSelector loads a user by a recovery selector, as part of the
|
|
authboss.RecoveringServerStorer interface.
|
|
*/
|
|
func (s *MongoStorer) LoadByRecoverSelector(ctx context.Context, selector string) (authboss.RecoverableUser, error) {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
New returns a new blank, unsaved user, as part of the
|
|
authboss.CreatingServerStorer interface.
|
|
*/
|
|
func (s *MongoStorer) New(ctx context.Context) authboss.User {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
Save persists an already in-storage user, as part of the authboss.ServerStorer
|
|
interface.
|
|
|
|
If the user does not exist in storage already, it returns
|
|
authboss.ErrUserNotFound instead.
|
|
*/
|
|
func (s *MongoStorer) Save(ctx context.Context, user authboss.User) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
UseRememberToken consumers a pid-token pair from a user if available, as part of
|
|
the authboss.RememberingServerStorer interface.
|
|
|
|
If it is not available, returns authboss.ErrTokenNotFound.
|
|
*/
|
|
func (s *MongoStorer) UseRememberToken(ctx context.Context, pid, token string) error {
|
|
panic("implement me")
|
|
}
|
|
|
|
/*
|
|
These blank vars allow compile-time verification of the fact that MongoStorer actually
|
|
implements the expected interfaces.
|
|
*/
|
|
var (
|
|
assertStorer = &MongoStorer{}
|
|
|
|
_ authboss.CreatingServerStorer = assertStorer
|
|
_ authboss.ConfirmingServerStorer = assertStorer
|
|
_ authboss.RecoveringServerStorer = assertStorer
|
|
_ authboss.RememberingServerStorer = assertStorer
|
|
)
|
|
|
|
/*
|
|
NewMongoStorer creates a new MongoStorer from a valid MongoDB client. It does
|
|
not perform any validation on it, so be sure not to pass nil.
|
|
*/
|
|
func NewMongoStorer(db *mongo.Client) *MongoStorer {
|
|
return &MongoStorer{
|
|
db: db,
|
|
}
|
|
}
|