github.com/influxdata/influxdb/v2@v2.7.6/credentials.go (about) 1 package influxdb 2 3 import ( 4 "context" 5 6 "github.com/influxdata/influxdb/v2/kit/platform/errors" 7 ) 8 9 var ( 10 // ErrCredentialsUnauthorized is the error returned when CredentialsV1 cannot be 11 // authorized. 12 ErrCredentialsUnauthorized = &errors.Error{ 13 Code: errors.EUnauthorized, 14 Msg: "Unauthorized", 15 } 16 ) 17 18 // SchemeV1 is an enumeration of supported authorization types 19 type SchemeV1 string 20 21 const ( 22 // SchemeV1Basic indicates the credentials came from an Authorization header using the BASIC scheme 23 SchemeV1Basic SchemeV1 = "basic" 24 25 // SchemeV1Token indicates the credentials came from an Authorization header using the Token scheme 26 SchemeV1Token SchemeV1 = "token" 27 28 // SchemeV1URL indicates the credentials came from the u and p query parameters 29 SchemeV1URL SchemeV1 = "url" 30 ) 31 32 // CredentialsV1 encapsulates the required credentials to authorize a v1 HTTP request. 33 type CredentialsV1 struct { 34 Scheme SchemeV1 35 Username string 36 Token string 37 } 38 39 type AuthorizerV1 interface { 40 Authorize(ctx context.Context, v1 CredentialsV1) (*Authorization, error) 41 }