github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/consumer/consumer.go (about) 1 package consumer 2 3 import ( 4 "github.com/kyma-incubator/compass/components/director/pkg/apperrors" 5 "github.com/kyma-incubator/compass/components/director/pkg/model" 6 "github.com/kyma-incubator/compass/components/hydrator/pkg/oathkeeper" 7 ) 8 9 // ConsumerType missing godoc 10 type ConsumerType string 11 12 const ( 13 // Runtime missing godoc 14 Runtime ConsumerType = "Runtime" 15 // ExternalCertificate missing godoc 16 ExternalCertificate ConsumerType = "External Certificate" 17 // Application missing godoc 18 Application ConsumerType = "Application" 19 // IntegrationSystem missing godoc 20 IntegrationSystem ConsumerType = "Integration System" 21 // User missing godoc 22 User ConsumerType = "Static User" 23 // SuperAdmin is a consumer type that is used only in our tests 24 SuperAdmin ConsumerType = "Super Admin" 25 // TechnicalClient is a consumer type that is used by Atom 26 TechnicalClient ConsumerType = "Technical Client" 27 // BusinessIntegration missing godoc 28 BusinessIntegration ConsumerType = "Business Integration" 29 // ManagedApplicationProviderOperator is a consumer type that is used by Managed Application Provider operator 30 ManagedApplicationProviderOperator ConsumerType = "Managed Application Provider Operator" 31 // ManagedApplicationConsumer is a consumer type that is used by Managed Application Provider operator 32 // when creating Certificate Subject Mappings 33 ManagedApplicationConsumer ConsumerType = "Managed Application Consumer" 34 // LandscapeResourceOperator is a consumer type that is used by Landscape Resource operator 35 LandscapeResourceOperator ConsumerType = "Landscape Resource Operator" 36 ) 37 38 // Consumer missing godoc 39 type Consumer struct { 40 ConsumerID string `json:"ConsumerID"` 41 ConsumerType `json:"ConsumerType"` 42 Flow oathkeeper.AuthFlow `json:"Flow"` 43 OnBehalfOf string `json:"onBehalfOf"` 44 Region string `json:"region"` 45 TokenClientID string `json:"tokenClientID"` 46 } 47 48 // MapSystemAuthToConsumerType missing godoc 49 func MapSystemAuthToConsumerType(refObj model.SystemAuthReferenceObjectType) (ConsumerType, error) { 50 switch refObj { 51 case model.ApplicationReference: 52 return Application, nil 53 case model.ExternalCertificateReference: 54 return ExternalCertificate, nil 55 case model.RuntimeReference: 56 return Runtime, nil 57 case model.IntegrationSystemReference: 58 return IntegrationSystem, nil 59 case model.TechnicalClientReference: 60 return TechnicalClient, nil 61 case model.BusinessIntegrationReference: 62 return BusinessIntegration, nil 63 case model.ManagedApplicationProviderOperatorReference: 64 return ManagedApplicationProviderOperator, nil 65 case model.ManagedApplicationConsumerReference: 66 return ManagedApplicationConsumer, nil 67 case model.LandscapeResourceOperatorConsumerReference: 68 return LandscapeResourceOperator, nil 69 case model.SuperAdminReference: 70 return SuperAdmin, nil 71 } 72 return "", apperrors.NewInternalError("unknown reference object type") 73 }