credentials.go 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. // GCPProjectID is the GCP project id
  15. GCPProjectID []byte `json:"gcp_project_id"`
  16. }
  17. type AWSCredential struct {
  18. // The AWS cluster ID
  19. // See https://github.com/kubernetes-sigs/aws-iam-authenticator#what-is-a-cluster-id
  20. AWSClusterID []byte `json:"aws_cluster_id"`
  21. // The AWS access key for this IAM user
  22. AWSAccessKeyID []byte `json:"aws_access_key_id"`
  23. // The AWS secret key for this IAM user
  24. AWSSecretAccessKey []byte `json:"aws_secret_access_key"`
  25. // An optional session token, if the user is assuming a role
  26. AWSSessionToken []byte `json:"aws_session_token"`
  27. // An optional region associated with this AWS credential
  28. AWSRegion []byte `json:"aws_region"`
  29. }
  30. type AzureCredential struct {
  31. // The Azure service principal key
  32. ServicePrincipalSecret []byte `json:"service_principal_secret"`
  33. // The ACR passwords, if set
  34. ACRPassword1 []byte `json:"acr_password_1"`
  35. ACRPassword2 []byte `json:"acr_password_2"`
  36. }
  37. type CredentialStorage interface {
  38. WriteOAuthCredential(oauthIntegration *integrations.OAuthIntegration, data *OAuthCredential) error
  39. GetOAuthCredential(oauthIntegration *integrations.OAuthIntegration) (*OAuthCredential, error)
  40. CreateOAuthToken(oauthIntegration *integrations.OAuthIntegration) (string, error)
  41. WriteGCPCredential(gcpIntegration *integrations.GCPIntegration, data *GCPCredential) error
  42. GetGCPCredential(gcpIntegration *integrations.GCPIntegration) (*GCPCredential, error)
  43. CreateGCPToken(gcpIntegration *integrations.GCPIntegration) (string, error)
  44. WriteAWSCredential(awsIntegration *integrations.AWSIntegration, data *AWSCredential) error
  45. GetAWSCredential(awsIntegration *integrations.AWSIntegration) (*AWSCredential, error)
  46. CreateAWSToken(awsIntegration *integrations.AWSIntegration) (string, error)
  47. WriteAzureCredential(azIntegration *integrations.AzureIntegration, data *AzureCredential) error
  48. GetAzureCredential(azIntegration *integrations.AzureIntegration) (*AzureCredential, error)
  49. CreateAzureToken(azIntegration *integrations.AzureIntegration) (string, error)
  50. }