credentials.go 3.2 KB

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