Documentation ¶
Index ¶
- Constants
- Variables
- func Decrypt(data, key string) (string, error)
- func EncipherPassword(plaintext string) (string, error)
- func Encrypt(key, data string) (string, string, error)
- func GetAudience() string
- func GetCurrentIdentity() (string, error)
- func GetEncryptionKey(fileName string) ([]byte, error)
- func GetEncryptionKeyFilename(tenant string, user string) string
- func ParseMetadataIdentityResponse(resp *http.Response) (string, error)
- func ParseSubjectFromToken(accessToken string) (string, error)
- func StorePassword(fileName, data string) (string, string, error)
- type AuthType
- type Authenticator
- type GcpClient
- type TokenResponse
Constants ¶
const ( Password = AuthType("password") Refresh = AuthType("refresh") ClientCredential = AuthType("clientcred") Certificate = AuthType("cert") FederatedThyOne = AuthType("thy-one") FederatedAws = AuthType("aws") FederatedAzure = AuthType("azure") FederatedGcp = AuthType("gcp") Oidc = AuthType("oidc") )
Types of supported authentication.
const ( GcpGceAuth = "gce" GcpIamAuth = "iam" )
Variables ¶
var KeyfileNotFoundError = errors.NewS("failed to find the encryption key") // trunk-ignore(golangci-lint/gochecknoglobals)
KeyfileNotFoundError is a global error variable is of type *ApiError, not regular error.
Functions ¶
func Decrypt ¶
Decrypt takes encrypted data and the key and attempts to decrypt the data back into plain text.
func EncipherPassword ¶
EncipherPassword takes in a plaintext password and returns the encrypted version of it. This is a higher-level function that looks up an encryption key found in the default path for tokens and key files. It then tries to encrypt the password using the encryption key, which must exist.
func Encrypt ¶
Encrypt returns a cipher text encrypted with AES-256, a key to decrypt, and any error that might have occurred.
func GetAudience ¶
func GetAudience() string
func GetCurrentIdentity ¶
func GetEncryptionKey ¶
GetEncryptionKey attempts to fetch and return the encryption key stored in fileName. If it does not find the key, it generates and returns a slice of random bytes as a new encryption key.
func GetEncryptionKeyFilename ¶
GetEncryptionKeyFilename creates and returns a filename for an encryption key given the tenant name and user name.
func ParseSubjectFromToken ¶
func StorePassword ¶
StorePassword takes a fileName in which it tries to find an encryption key. It also receives data to encrypt (password). It returns the encrypted data, key for later decryption, and any error that might have occurred.
Types ¶
type Authenticator ¶
type Authenticator interface { GetToken() (*TokenResponse, *errors.ApiError) WipeCachedTokens() error }
Authenticator is the interface used for authentication funcs.
func NewAuthenticator ¶
func NewAuthenticator(store store.Store, client requests.Client) Authenticator
NewAuthenticator returns a new authenticator.
func NewAuthenticatorDefault ¶
func NewAuthenticatorDefault() Authenticator
NewAuthenticatorDefault gets a new default authenticator.