github.com/Axway/agent-sdk@v1.1.101/pkg/apic/provisioning/definitions.go (about) 1 package provisioning 2 3 // default names of ARD and CRDs 4 const ( 5 APIKeyARD = "api-key" 6 BasicAuthARD = "http-basic" 7 APIKeyCRD = "api-key" 8 BasicAuthCRD = "http-basic" 9 OAuthSecretCRD = "oauth-secret" 10 OAuthPublicKeyCRD = "oauth-public-key" 11 OAuthIDPCRD = "oauth-idp" 12 13 OauthClientID = "clientId" 14 OauthClientSecret = "clientSecret" 15 OauthPublicKey = "publicKey" 16 OauthGrantType = "grantType" 17 OauthTokenAuthMethod = "tokenAuthMethod" 18 OauthScopes = "scopes" 19 OauthRedirectURIs = "redirectURLs" 20 OauthJwksURI = "jwksURI" 21 OauthJwks = "jwks" 22 OauthCertificate = "certificate" 23 OauthCertificateMetadata = "certificateMetadata" 24 OauthTLSAuthSANDNS = "tlsClientAuthSanDNS" 25 OauthTLSAuthSANEmail = "tlsClientAuthSanEmail" 26 OauthTLSAuthSANIP = "tlsClientAuthSanIP" 27 OauthTLSAuthSANURI = "tlsClientAuthSanURI" 28 OauthRegistrationToken = "registration" 29 30 IDPTokenURL = "idpTokenURL" 31 32 APIKey = "apiKey" 33 34 BasicAuthUsername = "username" 35 BasicAuthPassword = "password" 36 37 CredExpDetail = "Agent: CredentialExpired" 38 ) 39 40 // RequestType - the type of credential request being sent 41 type RequestType int 42 43 const ( 44 // RequestTypeProvision - provision new credentials 45 RequestTypeProvision RequestType = iota + 1 46 // RequestTypeRenew - renew existing credentials 47 RequestTypeRenew 48 ) 49 50 // String returns the string value of the RequestType enum 51 func (c RequestType) String() string { 52 return map[RequestType]string{ 53 RequestTypeProvision: "provision", 54 RequestTypeRenew: "renew", 55 }[c] 56 } 57 58 // Status - the Status of the request 59 type Status int 60 61 const ( 62 // Success - request was successful 63 Success Status = iota + 1 64 // Error - request failed 65 Error 66 // Pending - request is pending 67 Pending 68 ) 69 70 // String returns the string value of the Status 71 func (c Status) String() string { 72 return map[Status]string{ 73 Success: "Success", 74 Error: "Error", 75 Pending: "Pending", 76 }[c] 77 } 78 79 // State is the provisioning state 80 type State int 81 82 const ( 83 // Provision - state is waiting to provision 84 Provision = iota + 1 85 // Deprovision - state is waiting to deprovision 86 Deprovision 87 ) 88 89 // String returns the string value of the State 90 func (c State) String() string { 91 return map[State]string{ 92 Provision: "Provision", 93 Deprovision: "Deprovision", 94 }[c] 95 } 96 97 // CredentialAction - the Action the agent needs to take for this CredentialUpdate request 98 type CredentialAction int 99 100 const ( 101 // Enable - enable a credential 102 Enable CredentialAction = iota + 1 103 // Suspend - disable a credential 104 Suspend 105 // Rotate - create a new secret for a credential 106 Rotate 107 // Expire - mark the credential as expired 108 Expire 109 ) 110 111 // String returns the string value of the CredentialAction 112 func (c CredentialAction) String() string { 113 return map[CredentialAction]string{ 114 Enable: "Enable", 115 Suspend: "Suspend", 116 Rotate: "Rotate", 117 Expire: "Expire", 118 }[c] 119 } 120 121 // Provisioning - interface to be implemented by agents for access provisioning 122 type Provisioning interface { 123 AccessRequestDeprovision(AccessRequest) RequestStatus 124 AccessRequestProvision(AccessRequest) (RequestStatus, AccessData) 125 ApplicationRequestDeprovision(ApplicationRequest) RequestStatus 126 ApplicationRequestProvision(ApplicationRequest) RequestStatus 127 CredentialDeprovision(CredentialRequest) RequestStatus 128 CredentialProvision(CredentialRequest) (RequestStatus, Credential) 129 CredentialUpdate(CredentialRequest) (RequestStatus, Credential) 130 } 131 132 // ExpiredCredentialAction - the action to take on an expired credential 133 type ExpiredCredentialAction int 134 135 const ( 136 // DeprovisionExpiredCredential - deprovision expired credentials 137 DeprovisionExpiredCredential ExpiredCredentialAction = iota + 1 138 ) 139 140 // String returns the string value of the RequestType enum 141 func (c ExpiredCredentialAction) String() string { 142 return map[ExpiredCredentialAction]string{ 143 DeprovisionExpiredCredential: "deprovision", 144 }[c] 145 } 146 147 // String returns the string value of the RequestType enum 148 func ExpiredCredentialActionFromString(action string) ExpiredCredentialAction { 149 if val, ok := map[string]ExpiredCredentialAction{ 150 "deprovision": DeprovisionExpiredCredential, 151 }[action]; ok { 152 return val 153 } 154 return 0 155 }