@@ -57,6 +57,12 @@ const (
57
57
ClusterTopologySingleCluster = "SingleCluster"
58
58
ClusterTopologyMultiCluster = "MultiCluster"
59
59
60
+ OIDCAuthorizationTypeGroupMembership = "GroupMembership"
61
+ OIDCAuthorizationTypeUserID = "UserID"
62
+
63
+ OIDCAuthorizationMethodWorkforceIdentityFederation = "WorkforceIdentityFederation"
64
+ OIDCAuthorizationMethodWorkloadIdentityFederation = "WorkloadIdentityFederation"
65
+
60
66
LabelResourceOwner = "mongodb.com/v1.mongodbResourceOwner"
61
67
)
62
68
@@ -801,6 +807,13 @@ func (s *Security) IsTLSEnabled() bool {
801
807
return s .CertificatesSecretsPrefix != ""
802
808
}
803
809
810
+ func (s * Security ) IsOIDCEnabled () bool {
811
+ if s == nil || s .Authentication == nil || ! s .Authentication .Enabled {
812
+ return false
813
+ }
814
+ return s .Authentication .IsOIDCEnabled ()
815
+ }
816
+
804
817
// GetAgentMechanism returns the authentication mechanism that the agents will be using.
805
818
// The agents will use X509 if it is the only mechanism specified, otherwise they will use SCRAM if specified
806
819
// and no auth if no mechanisms exist.
@@ -878,7 +891,7 @@ func (s Security) RequiresClientTLSAuthentication() bool {
878
891
return false
879
892
}
880
893
881
- if len (s .Authentication .Modes ) == 1 && IsAuthPresent ( s .Authentication .Modes , util . X509 ) {
894
+ if len (s .Authentication .Modes ) == 1 && s .Authentication .IsX509Enabled ( ) {
882
895
return true
883
896
}
884
897
@@ -912,6 +925,10 @@ type Authentication struct {
912
925
// +optional
913
926
Ldap * Ldap `json:"ldap,omitempty"`
914
927
928
+ // Configuration for OIDC providers
929
+ // +optional
930
+ OIDCProviderConfigs []OIDCProviderConfig `json:"oidcProviderConfigs,omitempty"`
931
+
915
932
// Agents contains authentication configuration properties for the agents
916
933
// +optional
917
934
Agents AgentAuthentication `json:"agents,omitempty"`
@@ -920,7 +937,7 @@ type Authentication struct {
920
937
RequiresClientTLSAuthentication bool `json:"requireClientTLSAuthentication,omitempty"`
921
938
}
922
939
923
- // +kubebuilder:validation:Enum=X509;SCRAM;SCRAM-SHA-1;MONGODB-CR;SCRAM-SHA-256;LDAP
940
+ // +kubebuilder:validation:Enum=X509;SCRAM;SCRAM-SHA-1;MONGODB-CR;SCRAM-SHA-256;LDAP;OIDC
924
941
type AuthMode string
925
942
926
943
func ConvertAuthModesToStrings (authModes []AuthMode ) []string {
@@ -993,10 +1010,15 @@ func (a *Authentication) IsX509Enabled() bool {
993
1010
}
994
1011
995
1012
// IsLDAPEnabled determines if LDAP is to be enabled at the project level
996
- func (a * Authentication ) isLDAPEnabled () bool {
1013
+ func (a * Authentication ) IsLDAPEnabled () bool {
997
1014
return stringutil .Contains (a .GetModes (), util .LDAP )
998
1015
}
999
1016
1017
+ // IsOIDCEnabled determines if OIDC is to be enabled at the project level
1018
+ func (a * Authentication ) IsOIDCEnabled () bool {
1019
+ return stringutil .Contains (a .GetModes (), util .OIDC )
1020
+ }
1021
+
1000
1022
// GetModes returns the modes of the Authentication instance of an empty
1001
1023
// list if it is nil
1002
1024
func (a * Authentication ) GetModes () []string {
@@ -1033,6 +1055,68 @@ type Ldap struct {
1033
1055
UserCacheInvalidationInterval int `json:"userCacheInvalidationInterval"`
1034
1056
}
1035
1057
1058
+ type OIDCProviderConfig struct {
1059
+ // Unique label that identifies this configuration. This label is visible to your Ops Manager users and is used when
1060
+ // creating users and roles for authorization. It is case-sensitive and can only contain the following characters:
1061
+ // - alphanumeric characters (combination of a to z and 0 to 9)
1062
+ // - hyphens (-)
1063
+ // - underscores (_)
1064
+ // +kubebuilder:validation:Pattern="^[a-zA-Z0-9-_]+$"
1065
+ // +kubebuilder:validation:Required
1066
+ ConfigurationName string `json:"configurationName"`
1067
+
1068
+ // Issuer value provided by your registered IdP application. Using this URI, MongoDB finds an OpenID Provider
1069
+ // Configuration Document, which should be available in the /.wellknown/open-id-configuration endpoint.
1070
+ // +kubebuilder:validation:Required
1071
+ IssuerURI string `json:"issuerURI"`
1072
+
1073
+ // Entity that your external identity provider intends the token for.
1074
+ // Enter the audience value from the app you registered with external Identity Provider.
1075
+ // +kubebuilder:validation:Required
1076
+ Audience string `json:"audience"`
1077
+
1078
+ // Select GroupMembership to grant authorization based on IdP user group membership, or select UserID to grant
1079
+ // an individual user authorization.
1080
+ // +kubebuilder:validation:Required
1081
+ AuthorizationType OIDCAuthorizationType `json:"authorizationType"`
1082
+
1083
+ // The identifier of the claim that includes the user principal identity.
1084
+ // Accept the default value unless your IdP uses a different claim.
1085
+ // +kubebuilder:default=sub
1086
+ // +kubebuilder:validation:Required
1087
+ UserClaim string `json:"userClaim"`
1088
+
1089
+ // The identifier of the claim that includes the principal's IdP user group membership information.
1090
+ // Accept the default value unless your IdP uses a different claim, or you need a custom claim.
1091
+ // Required when selected GroupMembership as the authorization type, ignored otherwise
1092
+ // +kubebuilder:default=groups
1093
+ // +kubebuilder:validation:Optional
1094
+ GroupsClaim string `json:"groupsClaim,omitempty"`
1095
+
1096
+ // Configure single-sign-on for human user access to Ops Manager deployments with Workforce Identity Federation.
1097
+ // For programmatic, application access to Ops Manager deployments use Workload Identity Federation.
1098
+ // Only one Workforce Identity Federation IdP can be configured per MongoDB resource
1099
+ // +kubebuilder:validation:Required
1100
+ AuthorizationMethod OIDCAuthorizationMethod `json:"authorizationMethod"`
1101
+
1102
+ // Unique identifier for your registered application. Enter the clientId value from the app you
1103
+ // registered with an external Identity Provider.
1104
+ // Required when selected Workforce Identity Federation authorization method
1105
+ // +kubebuilder:validation:Optional
1106
+ ClientId string `json:"clientId,omitempty"`
1107
+
1108
+ // Tokens that give users permission to request data from the authorization endpoint.
1109
+ // Only used for Workforce Identity Federation authorization method
1110
+ // +kubebuilder:validation:Optional
1111
+ RequestedScopes []string `json:"requestedScopes,omitempty"`
1112
+ }
1113
+
1114
+ // +kubebuilder:validation:Enum=GroupMembership;UserID
1115
+ type OIDCAuthorizationType string
1116
+
1117
+ // +kubebuilder:validation:Enum=WorkforceIdentityFederation;WorkloadIdentityFederation
1118
+ type OIDCAuthorizationMethod string
1119
+
1036
1120
type SecretRef struct {
1037
1121
// +kubebuilder:validation:Required
1038
1122
Name string `json:"name"`
@@ -1142,7 +1226,14 @@ func (m *MongoDB) IsLDAPEnabled() bool {
1142
1226
if m .Spec .Security == nil || m .Spec .Security .Authentication == nil {
1143
1227
return false
1144
1228
}
1145
- return IsAuthPresent (m .Spec .Security .Authentication .Modes , util .LDAP )
1229
+ return m .Spec .Security .Authentication .IsLDAPEnabled ()
1230
+ }
1231
+
1232
+ func (m * MongoDB ) IsOIDCEnabled () bool {
1233
+ if m .Spec .Security == nil || m .Spec .Security .Authentication == nil {
1234
+ return false
1235
+ }
1236
+ return m .Spec .Security .Authentication .IsOIDCEnabled ()
1146
1237
}
1147
1238
1148
1239
func (m * MongoDB ) UpdateStatus (phase status.Phase , statusOptions ... status.Option ) {
@@ -1203,6 +1294,10 @@ func (m *MongoDB) GetStatus(...status.Option) interface{} {
1203
1294
return m .Status
1204
1295
}
1205
1296
1297
+ func (m * MongoDB ) GetStatusWarnings () []status.Warning {
1298
+ return m .Status .Warnings
1299
+ }
1300
+
1206
1301
func (m * MongoDB ) GetCommonStatus (... status.Option ) * status.Common {
1207
1302
return & m .Status .Common
1208
1303
}
0 commit comments