-
Notifications
You must be signed in to change notification settings - Fork 9
/
token_service.go
28 lines (25 loc) · 976 Bytes
/
token_service.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package service
import (
ijwt "github.com/madappgang/identifo/jwt"
"github.com/madappgang/identifo/model"
)
const (
// OfflineScope is a scope value to request refresh token.
OfflineScope = "offline"
)
// TokenService is an abstract token manager.
type TokenService interface {
NewAccessToken(u model.User, scopes []string, app model.AppData, requireTFA bool, tokenPayload map[string]interface{}) (ijwt.Token, error)
NewRefreshToken(u model.User, scopes []string, app model.AppData) (ijwt.Token, error)
RefreshAccessToken(token ijwt.Token) (ijwt.Token, error)
NewInviteToken(email, role string) (ijwt.Token, error)
NewResetToken(userID string) (ijwt.Token, error)
NewWebCookieToken(u model.User) (ijwt.Token, error)
Parse(string) (ijwt.Token, error)
String(ijwt.Token) (string, error)
Issuer() string
Algorithm() string
WebCookieTokenLifespan() int64
PublicKey() interface{} // we are not using crypto.PublicKey here to avoid dependencies
KeyID() string
}