credentials.go 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. SubscriptionID string `json:"subscription_id"`
  32. TenantID string `json:"tenant_id"`
  33. ClientID string `json:"client_id"`
  34. // The Azure service principal key
  35. ServicePrincipalSecret []byte `json:"service_principal_secret"`
  36. // The ACR passwords, if set
  37. ACRPassword1 []byte `json:"acr_password_1,omitempty"`
  38. ACRPassword2 []byte `json:"acr_password_2,omitempty"`
  39. AKSPassword []byte `json:"aks_password,omitempty"`
  40. }
  41. type GitlabCredential struct {
  42. AppClientID []byte `json:"app_client_id"`
  43. AppClientSecret []byte `json:"app_client_secret"`
  44. }
  45. type CredentialStorage interface {
  46. // OAuth
  47. WriteOAuthCredential(oauthIntegration *integrations.OAuthIntegration, data *OAuthCredential) error
  48. GetOAuthCredential(oauthIntegration *integrations.OAuthIntegration) (*OAuthCredential, error)
  49. CreateOAuthToken(oauthIntegration *integrations.OAuthIntegration) (string, error)
  50. // GCP
  51. WriteGCPCredential(gcpIntegration *integrations.GCPIntegration, data *GCPCredential) error
  52. GetGCPCredential(gcpIntegration *integrations.GCPIntegration) (*GCPCredential, error)
  53. CreateGCPToken(gcpIntegration *integrations.GCPIntegration) (string, error)
  54. // AWS
  55. WriteAWSCredential(awsIntegration *integrations.AWSIntegration, data *AWSCredential) error
  56. GetAWSCredential(awsIntegration *integrations.AWSIntegration) (*AWSCredential, error)
  57. CreateAWSToken(awsIntegration *integrations.AWSIntegration) (string, error)
  58. // Azure
  59. WriteAzureCredential(azIntegration *integrations.AzureIntegration, data *AzureCredential) error
  60. GetAzureCredential(azIntegration *integrations.AzureIntegration) (*AzureCredential, error)
  61. CreateAzureToken(azIntegration *integrations.AzureIntegration) (string, error)
  62. // Gitlab
  63. WriteGitlabCredential(giIntegration *integrations.GitlabIntegration, data *GitlabCredential) error
  64. GetGitlabCredential(giIntegration *integrations.GitlabIntegration) (*GitlabCredential, error)
  65. CreateGitlabToken(giIntegration *integrations.GitlabIntegration) (string, error)
  66. }