2021-07-21 23:04:00 +00:00
|
|
|
package token
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-10-17 22:51:10 +00:00
|
|
|
"errors"
|
2021-09-20 18:25:08 +00:00
|
|
|
|
2021-09-29 20:35:39 +00:00
|
|
|
"source.toby3d.me/website/oauth/internal/domain"
|
2021-07-21 23:04:00 +00:00
|
|
|
)
|
|
|
|
|
2021-11-14 21:17:25 +00:00
|
|
|
type (
|
|
|
|
GenerateOptions struct {
|
|
|
|
ClientID string
|
|
|
|
Me string
|
|
|
|
Scopes []string
|
|
|
|
NonceLength int
|
|
|
|
}
|
|
|
|
|
|
|
|
UseCase interface {
|
|
|
|
// Generate generates a new Token based on the session data.
|
|
|
|
Generate(ctx context.Context, opts GenerateOptions) (*domain.Token, error)
|
|
|
|
|
|
|
|
// Verify checks the AccessToken and returns the associated information.
|
|
|
|
Verify(ctx context.Context, accessToken string) (*domain.Token, error)
|
|
|
|
|
|
|
|
// Revoke revokes the AccessToken and blocks its further use.
|
|
|
|
Revoke(ctx context.Context, accessToken string) error
|
|
|
|
}
|
|
|
|
)
|
2021-10-17 22:51:10 +00:00
|
|
|
|
2021-10-17 23:12:00 +00:00
|
|
|
var ErrRevoke = errors.New("this token has been revoked")
|