-
Notifications
You must be signed in to change notification settings - Fork 0
/
auth.go
40 lines (31 loc) · 801 Bytes
/
auth.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
29
30
31
32
33
34
35
36
37
38
39
40
package fileshare
import "errors"
var ErrAuthMalformed = errors.New("malformed authentication token")
var ErrAuthInvalid = errors.New("invalid authentication token")
type TokenProvider interface {
GetUser(token string) (string, error)
GetToken(nickname string) (string, error)
}
type AuthPasswordUser struct {
Nickname string
Passwd string
}
type AuthPassword struct {
Users []AuthPasswordUser
}
type AuthGithub struct {
CallbackBaseURL string `yaml:"callback_base_url"`
ClientID string `yaml:"client_id"`
ClientSecret string `yaml:"client_secret"`
}
type OAuth2ProviderPayload struct {
Code string
State string
}
type OAuth2AuthProvider interface {
AuthProvider
Callback() (string, error)
}
type AuthProvider interface {
Authenticate(payload any) (string, error)
}