forked from influxdata/influxdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
credentials.go
37 lines (29 loc) · 987 Bytes
/
credentials.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
package influxdb
import "context"
var (
// ErrCredentialsUnauthorized is the error returned when CredentialsV1 cannot be
// authorized.
ErrCredentialsUnauthorized = &Error{
Code: EUnauthorized,
Msg: "Unauthorized",
}
)
// SchemeV1 is an enumeration of supported authorization types
type SchemeV1 string
const (
// SchemeV1Basic indicates the credentials came from an Authorization header using the BASIC scheme
SchemeV1Basic SchemeV1 = "basic"
// SchemeV1Token indicates the credentials came from an Authorization header using the Token scheme
SchemeV1Token SchemeV1 = "token"
// SchemeV1URL indicates the credentials came from the u and p query parameters
SchemeV1URL SchemeV1 = "url"
)
// CredentialsV1 encapsulates the required credentials to authorize a v1 HTTP request.
type CredentialsV1 struct {
Scheme SchemeV1
Username string
Token string
}
type AuthorizerV1 interface {
Authorize(ctx context.Context, v1 CredentialsV1) (*Authorization, error)
}