credentials.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 CredentialStorage interface {
  31. WriteOAuthCredential(oauthIntegration *integrations.OAuthIntegration, data *OAuthCredential) error
  32. GetOAuthCredential(oauthIntegration *integrations.OAuthIntegration) (*OAuthCredential, error)
  33. CreateOAuthToken(oauthIntegration *integrations.OAuthIntegration) (string, error)
  34. WriteGCPCredential(gcpIntegration *integrations.GCPIntegration, data *GCPCredential) error
  35. GetGCPCredential(gcpIntegration *integrations.GCPIntegration) (*GCPCredential, error)
  36. CreateGCPToken(gcpIntegration *integrations.GCPIntegration) (string, error)
  37. WriteAWSCredential(awsIntegration *integrations.AWSIntegration, data *AWSCredential) error
  38. GetAWSCredential(awsIntegration *integrations.AWSIntegration) (*AWSCredential, error)
  39. CreateAWSToken(awsIntegration *integrations.AWSIntegration) (string, error)
  40. }