blob: 44761092bb989c0c50c94893c898bfd6cb72c910 [file] [log] [blame]
Ash Wilson2a325802014-08-28 14:23:00 -04001package tokens
2
3import (
4 "errors"
5 "fmt"
6)
7
8func unacceptedAttributeErr(attribute string) error {
9 return fmt.Errorf("The base Identity V3 API does not accept authentication by %s", attribute)
10}
11
12func redundantWithTokenErr(attribute string) error {
13 return fmt.Errorf("%s may not be provided when authenticating with a TokenID", attribute)
14}
15
16func redundantWithUserID(attribute string) error {
17 return fmt.Errorf("%s may not be provided when authenticating with a UserID", attribute)
18}
19
20var (
21 // ErrAPIKeyProvided indicates that an APIKey was provided but can't be used.
22 ErrAPIKeyProvided = unacceptedAttributeErr("APIKey")
23
24 // ErrTenantIDProvided indicates that a TenantID was provided but can't be used.
25 ErrTenantIDProvided = unacceptedAttributeErr("TenantID")
26
27 // ErrTenantNameProvided indicates that a TenantName was provided but can't be used.
28 ErrTenantNameProvided = unacceptedAttributeErr("TenantName")
29
30 // ErrUsernameWithToken indicates that a Username was provided, but token authentication is being used instead.
31 ErrUsernameWithToken = redundantWithTokenErr("Username")
32
33 // ErrUserIDWithToken indicates that a UserID was provided, but token authentication is being used instead.
34 ErrUserIDWithToken = redundantWithTokenErr("UserID")
35
36 // ErrDomainIDWithToken indicates that a DomainID was provided, but token authentication is being used instead.
37 ErrDomainIDWithToken = redundantWithTokenErr("DomainID")
38
39 // ErrDomainNameWithToken indicates that a DomainName was provided, but token authentication is being used instead.s
40 ErrDomainNameWithToken = redundantWithTokenErr("DomainName")
41
42 // ErrUsernameOrUserID indicates that neither username nor userID are specified, or both are at once.
43 ErrUsernameOrUserID = errors.New("Exactly one of Username and UserID must be provided for password authentication")
44
45 // ErrDomainIDWithUserID indicates that a DomainID was provided, but unnecessary because a UserID is being used.
46 ErrDomainIDWithUserID = redundantWithUserID("DomainID")
47
48 // ErrDomainNameWithUserID indicates that a DomainName was provided, but unnecessary because a UserID is being used.
49 ErrDomainNameWithUserID = redundantWithUserID("DomainName")
50
51 // ErrDomainIDOrDomainName indicates that a username was provided, but no domain to scope it.
52 // It may also indicate that both a DomainID and a DomainName were provided at once.
53 ErrDomainIDOrDomainName = errors.New("You must provide exactly one of DomainID or DomainName to authenticate by Username")
54
55 // ErrMissingPassword indicates that no password was provided and no token is available.
56 ErrMissingPassword = errors.New("You must provide a password to authenticate")
57
58 // ErrScopeDomainIDOrDomainName indicates that a domain ID or Name was required in a Scope, but not present.
59 ErrScopeDomainIDOrDomainName = errors.New("You must provide exactly one of DomainID or DomainName in a Scope with ProjectName")
60
61 // ErrScopeProjectIDOrProjectName indicates that both a ProjectID and a ProjectName were provided in a Scope.
62 ErrScopeProjectIDOrProjectName = errors.New("You must provide at most one of ProjectID or ProjectName in a Scope")
63
64 // ErrScopeProjectIDAlone indicates that a ProjectID was provided with other constraints in a Scope.
65 ErrScopeProjectIDAlone = errors.New("ProjectID must be supplied alone in a Scope")
66
67 // ErrScopeDomainName indicates that a DomainName was provided alone in a Scope.
68 ErrScopeDomainName = errors.New("DomainName must be supplied with a ProjectName or ProjectID in a Scope.")
69
70 // ErrScopeEmpty indicates that no credentials were provided in a Scope.
71 ErrScopeEmpty = errors.New("You must provide either a Project or Domain in a Scope")
72)