credentials.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package credentials
  2. import "github.com/porter-dev/porter/internal/models/integrations"
  3. type OAuthCredential struct {
  4. // The ID issued to the client
  5. ClientID []byte `json:"client_id"`
  6. // The end-users's access token
  7. AccessToken []byte `json:"access_token"`
  8. // The end-user's refresh token
  9. RefreshToken []byte `json:"refresh_token"`
  10. }
  11. type GCPCredential struct {
  12. // KeyData for a service account for GCP connectors
  13. GCPKeyData []byte `json:"gcp_key_data"`
  14. }
  15. type AWSCredential struct {
  16. // The AWS cluster ID
  17. // See https://github.com/kubernetes-sigs/aws-iam-authenticator#what-is-a-cluster-id
  18. AWSClusterID []byte `json:"aws_cluster_id"`
  19. // The AWS access key for this IAM user
  20. AWSAccessKeyID []byte `json:"aws_access_key_id"`
  21. // The AWS secret key for this IAM user
  22. AWSSecretAccessKey []byte `json:"aws_secret_access_key"`
  23. // An optional session token, if the user is assuming a role
  24. AWSSessionToken []byte `json:"aws_session_token"`
  25. }
  26. type CredentialStorage interface {
  27. WriteOAuthCredential(oauthIntegration *integrations.OAuthIntegration, data *OAuthCredential) error
  28. GetOAuthCredential(oauthIntegration *integrations.OAuthIntegration) (*OAuthCredential, error)
  29. CreateOAuthToken(oauthIntegration *integrations.OAuthIntegration) (string, error)
  30. WriteGCPCredential(gcpIntegration *integrations.GCPIntegration, data *GCPCredential) error
  31. GetGCPCredential(gcpIntegration *integrations.GCPIntegration) (*GCPCredential, error)
  32. CreateGCPToken(gcpIntegration *integrations.GCPIntegration) (string, error)
  33. WriteAWSCredential(awsIntegration *integrations.AWSIntegration, data *AWSCredential) error
  34. GetAWSCredential(awsIntegration *integrations.AWSIntegration) (*AWSCredential, error)
  35. CreateAWSToken(awsIntegration *integrations.AWSIntegration) (string, error)
  36. }