@@ -41,14 +41,69 @@ public class AuthenticatorConfig extends AbstractConfig {
41
41
public static final String PRINCIPAL_OPT = "auth.gssapi.principal" ;
42
42
public static final String SERVICE_OPT = "auth.gssapi.service" ;
43
43
44
+ /*
45
+ # oidc_options:
46
+ # # OIDC Authentication server url (required when "oidc" authentication scheme is used).
47
+ # issuer: https://auth.example.com/realms/my-realm
48
+ #
49
+ # # Array of accepted OIDC clients (by default all clients are accepted).
50
+ # accepted_audience: []
51
+ #
52
+ # # Access token claim used to identify the user in the database (by default the "preferred_username"
53
+ # # claim is used). When defined, the claim must exist at the top-level of the access token's JWT.
54
+ # user_name_claim:
55
+ #
56
+ # # Array of claims used to identify the user roles in the database. For example, setting this
57
+ # # configuration to "[ realm_roles.roles ]" will assume all OIDC realm roles. If the claim doesn't
58
+ # # exist or does not identify an array of strings in the JWT, the setting will be ignored. Roles
59
+ # # defined in these claims must be previously defined in the database such that any privilege grant
60
+ # # is recognized and validated.
61
+ # user_roles_claims: []
62
+ #
63
+ # # Set to true to initiate a TLS encrypted connections. Defaults to false. If case of
64
+ # # truststore_path being set, it will default to true.
65
+ # use_tls: false
66
+ #
67
+ # # Sets the keystore path with valid certificates to establish encrypted connections with the OIDC Server.
68
+ # # When TLS is enabled, failure to set this option or an invalid path will result in an error.
69
+ # truststore_path:
70
+ # # Keystore password
71
+ # truststore_password:
72
+ # # Keystore type (JKS or PKCS12). By default, the trustore type is inferred from the keystore
73
+ # # extension. For `.p12`, `.pkcs12`, or `.pfx` files, PKCS12 is used. For `.keystore` or
74
+ # # `.jks` files, JKS is used. In case the keystore type cannot be inferred from the extension,
75
+ # # this option must be set.
76
+ # truststore_type: jks
77
+ #
78
+ # # Compatibility option, allowing older drivers to use OIDC authentication via password
79
+ # # authentication, by using a pre-configurable username and passing an OIDC JWT access token as
80
+ # # password. Defaults to false.
81
+ # # allow_token_via_password_authentication: false
82
+ # # When the above option is true, it allows configuring the username which will be used
83
+ # # to detect that an OIDC JWT access token is being sent as password.
84
+ # # token_username: oauth-bearer
85
+ */
86
+
87
+ public static final String OIDC_ISSUER = "auth.oidc.issuer" ;
88
+ public static final String OIDC_ACCEPTED_AUDIENCE = "auth.oidc.accepted_audience" ;
89
+ public static final String OIDC_USER_NAME_CLAIM = "auth.oidc.user_name_claim" ;
90
+ public static final String OIDC_USER_ROLES_CLAIMS = "auth.oidc.user_roles_claims" ;
91
+ public static final String OIDC_USE_TLS = "auth.oidc.use_tls" ;
92
+ public static final String OIDC_TRUSTSTORE_PATH = "auth.oidc.truststore_path" ;
93
+ public static final String OIDC_TRUSTSTORE_PASSWORD = "auth.oidc.truststore_password" ;
94
+ public static final String OIDC_TRUSTSTORE_TYPE = "auth.oidc.truststore_type" ;
95
+ public static final String OIDC_ALLOW_TOKEN_VIA_PASSWORD_AUTHENTICATION =
96
+ "auth.oidc.allow_token_via_password_authentication" ;
97
+ public static final String OIDC_TOKEN_USERNAME = "auth.oidc.token_username" ;
98
+
44
99
private static final Logger log = LoggerFactory .getLogger (AuthenticatorConfig .class );
45
100
public static final ConfigDef CONFIG_DEF =
46
101
new ConfigDef ()
47
102
.define (
48
103
PROVIDER_OPT ,
49
104
ConfigDef .Type .STRING ,
50
105
"None" ,
51
- ConfigDef .ValidString .in ("None" , "PLAIN" , "GSSAPI" ),
106
+ ConfigDef .ValidString .in ("None" , "PLAIN" , "GSSAPI" , "OIDC" ),
52
107
ConfigDef .Importance .HIGH ,
53
108
"Authentication provider" )
54
109
.define (
@@ -80,7 +135,74 @@ public class AuthenticatorConfig extends AbstractConfig {
80
135
ConfigDef .Type .STRING ,
81
136
"dse" ,
82
137
ConfigDef .Importance .HIGH ,
83
- "SASL service name to use for GSSAPI provider authentication" );
138
+ "SASL service name to use for GSSAPI provider authentication" )
139
+ .define (
140
+ OIDC_ISSUER ,
141
+ ConfigDef .Type .STRING ,
142
+ "" ,
143
+ ConfigDef .Importance .HIGH ,
144
+ "OIDC Authentication server url" )
145
+ .define (
146
+ OIDC_ACCEPTED_AUDIENCE ,
147
+ ConfigDef .Type .LIST ,
148
+ "" ,
149
+ ConfigDef .Importance .HIGH ,
150
+ "Array of accepted OIDC clients" )
151
+ .define (
152
+ OIDC_USER_NAME_CLAIM ,
153
+ ConfigDef .Type .STRING ,
154
+ "preferred_username" ,
155
+ ConfigDef .Importance .HIGH ,
156
+ "Access token claim used to identify the user in the database" )
157
+ .define (
158
+ OIDC_USER_ROLES_CLAIMS ,
159
+ ConfigDef .Type .LIST ,
160
+ "" ,
161
+ ConfigDef .Importance .HIGH ,
162
+ "Array of claims used to identify the user roles in the database" )
163
+ .define (
164
+ OIDC_USE_TLS ,
165
+ ConfigDef .Type .BOOLEAN ,
166
+ false ,
167
+ ConfigDef .Importance .HIGH ,
168
+ "Set to true to initiate a TLS encrypted connections. Defaults to false. If case of "
169
+ + "truststore_path being set, it will default to true." )
170
+ .define (
171
+ OIDC_TRUSTSTORE_PATH ,
172
+ ConfigDef .Type .STRING ,
173
+ "" ,
174
+ ConfigDef .Importance .HIGH ,
175
+ "Sets the keystore path with valid certificates to establish encrypted connections with the OIDC Server." )
176
+ .define (
177
+ OIDC_TRUSTSTORE_PASSWORD ,
178
+ ConfigDef .Type .PASSWORD ,
179
+ "" ,
180
+ ConfigDef .Importance .HIGH ,
181
+ "Keystore password" )
182
+ .define (
183
+ OIDC_TRUSTSTORE_TYPE ,
184
+ ConfigDef .Type .STRING ,
185
+ "jks" ,
186
+ ConfigDef .Importance .HIGH ,
187
+ "Keystore type (JKS or PKCS12). By default, the trustore type is inferred from the keystore "
188
+ + "extension. For `.p12`, `.pkcs12`, or `.pfx` files, PKCS12 is used. For `.keystore` or "
189
+ + "`.jks` files, JKS is used. In case the keystore type cannot be inferred from the extension, "
190
+ + "this option must be set." )
191
+ .define (
192
+ OIDC_ALLOW_TOKEN_VIA_PASSWORD_AUTHENTICATION ,
193
+ ConfigDef .Type .BOOLEAN ,
194
+ false ,
195
+ ConfigDef .Importance .HIGH ,
196
+ "Compatibility option, allowing older drivers to use OIDC authentication via password "
197
+ + "authentication, by using a pre-configurable username and passing an OIDC JWT access token as "
198
+ + "password." )
199
+ .define (
200
+ OIDC_TOKEN_USERNAME ,
201
+ ConfigDef .Type .STRING ,
202
+ "oauth-bearer" ,
203
+ ConfigDef .Importance .HIGH ,
204
+ "When the above option is true, it allows configuring the username which will be used "
205
+ + "to detect that an OIDC JWT access token is being sent as password." );
84
206
85
207
@ Nullable private final Path keyTabPath ;
86
208
@@ -101,9 +223,14 @@ public AuthenticatorConfig(Map<String, String> authSettings) {
101
223
if (getService ().isEmpty ()) {
102
224
throw new ConfigException (SERVICE_OPT , "<empty>" , "is required" );
103
225
}
104
-
105
226
assertAccessibleFile (keyTabPath , KEYTAB_OPT );
106
227
}
228
+
229
+ if (provider == Provider .OIDC ) {
230
+ if (getString (OIDC_ISSUER ).isEmpty ()) {
231
+ throw new ConfigException (OIDC_ISSUER , "<empty>" , "is required" );
232
+ }
233
+ }
107
234
}
108
235
109
236
/**
@@ -139,6 +266,19 @@ private static Map<String, String> sanitizeAuthSettings(Map<String, String> auth
139
266
mutated .put (PRINCIPAL_OPT , getPrincipalFromKeyTab (keyTabPath .toString ()));
140
267
}
141
268
}
269
+
270
+ if ("OIDC" .equals (provider )) {
271
+ // OIDC provider requires issuer to be set.
272
+ if (!mutated .containsKey (OIDC_ISSUER ) || mutated .get (OIDC_ISSUER ).isEmpty ()) {
273
+ throw new ConfigException (OIDC_ISSUER , "<empty>" , "is required for OIDC authentication" );
274
+ }
275
+ // If truststore path is set, use TLS.
276
+ if (mutated .containsKey (OIDC_TRUSTSTORE_PATH )
277
+ && !mutated .get (OIDC_TRUSTSTORE_PATH ).isEmpty ()) {
278
+ mutated .put (OIDC_USE_TLS , "true" );
279
+ }
280
+ }
281
+
142
282
return ImmutableMap .<String , String >builder ().putAll (mutated ).build ();
143
283
}
144
284
@@ -191,7 +331,7 @@ public Provider getProvider() {
191
331
return Provider .valueOf (providerString );
192
332
} catch (IllegalArgumentException e ) {
193
333
throw new ConfigException (
194
- PROVIDER_OPT , providerString , "valid values are None, PLAIN, GSSAPI" );
334
+ PROVIDER_OPT , providerString , "valid values are None, PLAIN, GSSAPI, OIDC " );
195
335
}
196
336
}
197
337
@@ -226,12 +366,23 @@ public String toString() {
226
366
PASSWORD_OPT ,
227
367
KEYTAB_OPT ,
228
368
PRINCIPAL_OPT ,
229
- SERVICE_OPT );
369
+ SERVICE_OPT ,
370
+ // OIDC opts
371
+ OIDC_ISSUER ,
372
+ OIDC_ACCEPTED_AUDIENCE ,
373
+ OIDC_USER_NAME_CLAIM ,
374
+ OIDC_USE_TLS ,
375
+ OIDC_TRUSTSTORE_PATH ,
376
+ OIDC_TRUSTSTORE_PASSWORD ,
377
+ OIDC_TRUSTSTORE_TYPE ,
378
+ OIDC_ALLOW_TOKEN_VIA_PASSWORD_AUTHENTICATION ,
379
+ OIDC_TOKEN_USERNAME );
230
380
}
231
381
232
382
public enum Provider {
233
383
None ,
234
384
PLAIN ,
235
- GSSAPI
385
+ GSSAPI ,
386
+ OIDC
236
387
}
237
388
}
0 commit comments