-
Notifications
You must be signed in to change notification settings - Fork 0
/
ident.go
41 lines (32 loc) · 1.18 KB
/
ident.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
41
package ident
import (
"context"
"errors"
"net/http"
"github.com/ViBiOh/auth/pkg/model"
)
var (
// ErrUnknownIdentType occurs when identification type in unknown
ErrUnknownIdentType = errors.New("unknown identification type")
// ErrEmptyAuth occurs when authorization content is not found
ErrEmptyAuth = errors.New("empty authorization content")
// ErrMalformedAuth occurs when authorization content is malformed
ErrMalformedAuth = errors.New("malformed authorization content")
// ErrInvalidState occurs when state is not consistent
ErrInvalidState = errors.New("invalid state provided for oauth")
// ErrInvalidCode occurs when code is no valid
ErrInvalidCode = errors.New("invalid code provided for oauth")
)
// Service provide methods for dealing with identification
type Service interface {
GetUser(context.Context, string) (*model.User, error)
OnError(http.ResponseWriter, *http.Request, error)
}
// Auth is a provider of identification methods
type Auth interface {
GetName() string
GetUser(context.Context, string) (*model.User, error)
Redirect(http.ResponseWriter, *http.Request)
Login(*http.Request) (string, error)
OnLoginError(http.ResponseWriter, *http.Request, error)
}