-
Notifications
You must be signed in to change notification settings - Fork 0
/
ident.go
32 lines (24 loc) · 863 Bytes
/
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
package ident
import (
"context"
"errors"
"net/http"
"github.com/ViBiOh/auth/v2/pkg/model"
)
var (
// ErrMalformedAuth occurs when authorization content is malformed
ErrMalformedAuth = errors.New("malformed authorization content")
// ErrUnavailableService occurs when service is unavailable
ErrUnavailableService = errors.New("unavailable ident service")
// ErrInvalidCredentials occurs when credentials failed
ErrInvalidCredentials = errors.New("invalid credentials")
)
// Provider provides methods for dealing with identification
type Provider interface {
// IsMatching checks if header content match provider
IsMatching(string) bool
// GetUser returns User found in content header
GetUser(context.Context, string) (model.User, error)
// OnError handles HTTP request when login fails
OnError(http.ResponseWriter, *http.Request, error)
}