You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 23, 2023. It is now read-only.
@@ -202,6 +202,8 @@ The _secureResponse()_ method is provided to allow post processing on the respon
202
202
203
203
The _cleanSubject()_ is provided to allow for cleanup after a caller is logged out. For example, an authentication mechanism that stores state within a cookie can remove that cookie here.
204
204
205
+
The _HttpMessageContext_ interface defines methods that an _HttpAuthenticationMechanism_ can invoke to communicate with the JASPIC _ServerAuthModule_ (bridge module) that invokes it. The _HttpMessageContextWrapper_ provides an implementation of the interface, and can be used, in a manner similar to _HttpServletRequestWrapper_, to provide custom behavior. See javadoc for a detailed description of _HttpMessageContext_ and _HttpMessageContextWrapper_. See below for more on the JASPIC bridge module.
206
+
205
207
=== Installation and Configuration
206
208
207
209
An _HttpAuthenticationMechanism_ must be a CDI bean, and is therefore visible to the container through CDI if it is packaged in a bean archive, which generally includes Java EE modules and application archives, as well as other archives and classes that are not part of an application, but are required by the Java EE specification to be visible to applications. See the CDI specification for details on bean archives and bean discovery. An _HttpAuthenticationMechanism_ is assumed to be normal scoped.
@@ -214,9 +216,9 @@ The container decides which _HttpAuthenticationMechanism_ to place in service us
214
216
215
217
* The container MAY override an application's chosen _HttpAuthenticationMechanism_ with one selected by the container, but SHOULD do so only if explicitly configured to.
216
218
* If the container does not override the application, it MUST place in service any _HttpAuthenticationMechanism_ that is provided, either directly or via annotation, by the application.
217
-
* If the application makes more than one _HttpAuthenticationMechanism_ available, either directly or via annotation or both, the results are undefined.
219
+
* If the application makes more than one _HttpAuthenticationMechanism_ available, either directly or via annotation or both, the results are undefined by this specification.
218
220
* If the application does not supply an _HttpAuthenticationMechanism_, or select one of the built-in mechanisms, the container MAY choose an _HttpAuthenticationMechanism_ to place in service, but is NOT REQUIRED to do so.
219
-
* If neither the application nor the container makes an _HttpAuthenticationMechanism_ available, then _HttpAuthenticationMechanism_ is not used.
221
+
* If the application does not make an _HttpAuthenticationMechanism_ available, and the container does not choose one to place in service, then _HttpAuthenticationMechanism_ is not used.
220
222
221
223
The container MUST use JASPIC when placing an _HttpAuthenticationMechanism_ in service. The container MUST supply a "bridge" _ServerAuthModule_ that integrates _HttpAuthenticationMechanism_ with JASPIC. The bridge module MUST look up the correct _HttpAuthenticationMechanism_ using CDI, then delegate to the _HttpAuthenticationMechanism_ when the bridge module's methods are invoked. Since the method signatures and return values of the two interfaces are similar, but not the same, the bridge module MUST convert back and forth.
222
224
@@ -234,14 +236,153 @@ A Java EE container MUST support built-in beans for the following _HttpAuthentic
234
236
235
237
All of these beans MUST have the qualifier @Default and the scope @ApplicationScoped, as defined by the CDI specification.
236
238
237
-
All of the built-in beans MUST support authentication using _IdentityStore_, as described in the <<identityStore.asciidoc#identity-store,Identity Store>> section, but MAY fall-back to container-specific methods if no _IdentityStore_ is available.
239
+
All of the built-in beans MUST support authentication using _IdentityStore_, as described in the <<identityStore.asciidoc#identity-store,Identity Store>> chapter, but MAY fall-back to container-specific methods if no _IdentityStore_ is available.
240
+
241
+
See also <<Implementation Notes>> later in this chapter.
242
+
243
+
The annotations are defined as shown in the following sections.
244
+
245
+
==== BASIC Annotation
246
+
247
+
The following annotation is used to configure the built-in BASIC authentication mechanism.
248
+
249
+
[source,java]
250
+
----
251
+
@Retention(RUNTIME)
252
+
@Target(TYPE)
253
+
public @interface BasicAuthenticationMechanismDefinition {
254
+
255
+
/**
256
+
* Name of realm that will be sent via the <code>WWW-Authenticate</code> header.
257
+
* <p>
258
+
* Note that contrary to what happens in some proprietary Servlet products, this
259
+
* realm name <b>does not</b> couple a named identity store configuration to the
260
+
* authentication mechanism.
261
+
*
262
+
* @return Name of realm
263
+
*/
264
+
String realmName() default "";
265
+
}
266
+
----
267
+
268
+
==== FORM Annotation
269
+
270
+
The following annotation is used to configure the built-in FORM authentication mechanism.
271
+
272
+
[source,java]
273
+
----
274
+
@Retention(RUNTIME)
275
+
@Target(TYPE)
276
+
public @interface FormAuthenticationMechanismDefinition {
277
+
278
+
@Nonbinding
279
+
LoginToContinue loginToContinue();
280
+
}
281
+
----
282
+
283
+
See also the _LoginToContinue_ annotation below.
284
+
285
+
==== Custom FORM Annotation
286
+
287
+
The following annotation is used to configure the built-in Custom FORM authentication mechanism.
288
+
See also <<Custom FORM Notes>> later in this chapter.
289
+
290
+
[source,java]
291
+
----
292
+
@Retention(RUNTIME)
293
+
@Target(TYPE)
294
+
public @interface CustomFormAuthenticationMechanismDefinition {
295
+
296
+
@Nonbinding
297
+
LoginToContinue loginToContinue();
298
+
}
299
+
----
300
+
301
+
See also the _LoginToContinue_ annotation below.
302
+
303
+
==== LoginToContinue Annotation
304
+
305
+
The _LoginToContinue_ annotation is used to configure the login page, error page, and redirect/forward behavior for a form-based authentication mechanism:
306
+
307
+
[source,java]
308
+
----
309
+
@Inherited
310
+
@InterceptorBinding
311
+
@Retention(RUNTIME)
312
+
@Target(TYPE)
313
+
public @interface LoginToContinue {
314
+
315
+
@Nonbinding
316
+
String loginPage() default "/login";
317
+
318
+
@Nonbinding
319
+
boolean useForwardToLogin() default true;
320
+
321
+
@Nonbinding
322
+
String errorPage() default "/login-error";
323
+
}
324
+
----
325
+
326
+
==== RememberMe Annotation
327
+
328
+
The _RememberMe_ annotation is used to configure a _RememberMeIdentityStore_, which must be provided by the application. To use _RememberMe_, the application must provide an _HttpAuthenticationMechanism_ (or configure one of the built-in mechanisms), and annotate the _HttpAuthenticationMechanism_ (or built-in annotation) with the _RememberMe_ annotation.
329
+
330
+
[source,java]
331
+
----
332
+
@Inherited
333
+
@InterceptorBinding
334
+
@Retention(RUNTIME)
335
+
@Target(TYPE)
336
+
public @interface RememberMe {
337
+
338
+
@Nonbinding
339
+
int cookieMaxAgeSeconds() default 86400; // 1 day
340
+
341
+
@Nonbinding
342
+
boolean cookieSecureOnly() default true;
343
+
344
+
@Nonbinding
345
+
boolean cookieHttpOnly() default true;
346
+
347
+
@Nonbinding
348
+
String cookieName() default "JREMEMBERMEID";
349
+
350
+
@Nonbinding
351
+
String isRememberMeExpression() default "";
352
+
}
353
+
----
354
+
355
+
The container MUST provide an interceptor implementation that backs the _RememberMe_ annotation and intercepts calls to the configured _HttpAuthenticationMechanism_. The interceptor MUST behave as follows when intercepting calls to the _HttpAuthenticationMechanism_:
356
+
357
+
Intercepting _validateRequest()_::
358
+
* Determine whether there is a RememberMe cookie in the request
359
+
* If the cookie is present:
360
+
** Use it to construct a _RememberMeCredential_ and call the _validate()_ method of the _RememberMeIdentityStore_.
361
+
** If the validate succeeds, call _HttpMessageContext.notifyContainerAboutLogin(), passing the CallerPrincipal and CallerGroups returned by _validate().
362
+
** If the validate fails, remove the cookie from the request.
363
+
* If no cookie is present, or if the attempt to validate a cookie failed, authenticate the caller normally by calling _proceed() on the _InvocationContext_.
364
+
* If authentication succeeds, and the caller has requested to be remembered, as determined by evaluating the _isRememberMeExpression()_, then:
365
+
** Call the _generateLoginToken()_ method of the _RememberMeIdentityStore_.
366
+
** Set the new cookie with parameters as configured on the _RememberMe_ annotation.
367
+
368
+
Intercepting _secureResponse()_::
369
+
* The _secureResponse() method SHOULD NOT be intercepted.
370
+
371
+
Intercepting _cleanSubject()_::
372
+
* If there is a RememberMe cookie in the request, then:
373
+
** Remove the cookie.
374
+
** Call the _removeLoginToken()_ method of the _RememberMeIdentityStore_.
375
+
376
+
See also the description of _RememberMeIdentityStore_ in the <<identityStore.asciidoc#identity-store,Identity Store>> chapter.
238
377
239
378
==== Implementation Notes ====
240
379
241
380
The Servlet spec, section 14.4 item 18, describes requirements for supporting BASIC and FORM authentication via the web.xml _login-config_ element. This specification requires that implementations of BASIC and FORM be made available as _HttpAuthenticationMechanism_ CDI beans. The servlet container is NOT REQUIRED to implement separate and independent mechanisms to satisfy each requirement. Instead, the container MAY choose to provide a single mechanism, for each of BASIC and FORM, that meets the requirements of both specifications; i.e., an implementation that can be configured via _login-config_, but which is also made available as an _HttpAuthenticationMechanism_ if the application uses the corresponding annotation. Equally, the container is NOT REQUIRED to provide a unified implementation, and MAY satisfy the two requirements using separate, independent implementations.
242
381
243
382
An implementation of BASIC or FORM is NOT REQUIRED to support _IdentityStore_ when configured via _login-config_, regardless of whether the container has provided a single mechanism or separate mechanisms to satisfy the _login-config_ and _HttpAuthenticationMechanism_ requirements. Implementations MAY support _IdentityStore_ for all configuration methods.
244
383
384
+
If an application provides an _HttpAuthenticationMechanism_ and also configures a _login-config_ element in web.xml, the container SHOULD fail deployment, but MAY choose to proceed, using only the _HttpAuthenticationMechanism_ (i.e., ignoring the _login-config_ from web.xml).
385
+
245
386
==== Custom FORM Notes ====
246
387
247
388
The Custom FORM variant is intended to align better with modern Java EE technologies such as CDI, Expression Language, Bean Validation and specifically JSF.
@@ -319,57 +460,6 @@ public class LoginBacking {
319
460
}
320
461
----
321
462
322
-
The annotations are defined as shown in the following sections.
323
-
324
-
==== BASIC Annotation
325
-
326
-
[source,java]
327
-
----
328
-
@Retention(RUNTIME)
329
-
@Target(TYPE)
330
-
public @interface BasicAuthenticationMechanismDefinition {
331
-
332
-
/**
333
-
* Name of realm that will be send via the <code>WWW-Authenticate</code> header.
334
-
* <p>
335
-
* Note that contrary to what happens in some proprietary Servlet products, this
336
-
* realm name <b>does not</b> couple a named identity store configuration to the
337
-
* authentication mechanism.
338
-
*
339
-
* @return Name of realm
340
-
*/
341
-
String realmName() default "";
342
-
}
343
-
----
344
-
345
-
==== FORM Annotation
346
-
347
-
[source,java]
348
-
----
349
-
@Retention(RUNTIME)
350
-
@Target(TYPE)
351
-
public @interface FormAuthenticationMechanismDefinition {
352
-
353
-
@Nonbinding
354
-
LoginToContinue loginToContinue();
355
-
356
-
}
357
-
----
358
-
359
-
==== Custom FORM Annotation
360
-
361
-
[source,java]
362
-
----
363
-
@Retention(RUNTIME)
364
-
@Target(TYPE)
365
-
public @interface CustomFormAuthenticationMechanismDefinition {
366
-
367
-
@Nonbinding
368
-
LoginToContinue loginToContinue();
369
-
370
-
}
371
-
----
372
-
373
463
=== Relationship to other specifications
374
464
375
465
An _HttpAuthenticationMechanism_ is a CDI bean, as defined by the CDI (JSR 346) specification. The methods defined by the _HttpAuthenticationMechanism_ closely map to the methods and semantics of a _ServerAuthModule_ as defined by the Servlet Container Profile of the JASPIC (JSR 196) specification (but an _HttpAuthenticationMechanism_ is itself not a _ServerAuthModule_). The servlet container MUST use JASPIC mechanisms to arrange for an _HttpAuthenticationMechanism_ to be placed in service.
Copy file name to clipboardExpand all lines: src/main/doc/concepts.asciidoc
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -159,10 +159,10 @@ HAM::
159
159
Abbreviation for _HttpAuthenticationMechanism_, an interface defined by this specification.
160
160
161
161
Identity Store::
162
-
An Identity Store is a component that can access application-specific security data such as users, roles, and permissions. It can be thought of as a security-specific DAO (Data Access Object). Synonyms: security provider, repository, store, login module (JAAS), identity manager, service provider, relying party, authenticator, user service. Identity Stores usually have a 1-to-1 correlation with a data source such as a relational database, LDAP directory, file system, or other similar resource. As such, implementations of the _IdentityStore_ interface use data source-specific APIs to discover authorization data (roles, permissions, etc), such as JDBC, File IO, Hibernate or JPA, or any other Data Access API.
162
+
An Identity Store is a component that can access application-specific security data such as users, groups, roles, and permissions. It can be thought of as a security-specific DAO (Data Access Object). Synonyms: security provider, repository, store, login module (JAAS), identity manager, service provider, relying party, authenticator, user service. Identity Stores usually have a 1-to-1 correlation with a data source such as a relational database, LDAP directory, file system, or other similar resource. As such, implementations of the _IdentityStore_ interface use data source-specific APIs to discover authorization data (roles, permissions, etc), such as JDBC, File IO, Hibernate or JPA, or any other Data Access API.
163
163
164
164
JASPIC::
165
-
Java Authentication SPI for Containers.
165
+
The Java Authentication SPI for Containers (JSR-196).
166
166
167
167
SAM::
168
168
Abbreviation for _ServerAuthModule_, an interface defined by JASPIC.
@@ -175,9 +175,9 @@ The following general requirments are defined by this specification.
175
175
176
176
Various Java EE specifications define how roles are declared for an application, and how access to application resources can be restricted to users that have a specific role. The specifications are largely silent on the question of how users are assigned to roles, however. Most application servers have proprietary mechanisms for determining the roles a user has.
177
177
178
-
Application servers MUST provide a default mapping from group names to roles. That is, a caller who is a member of group "foo" is considered to have role "foo". This default mapping MAY be overridden by proprietary configuration, but, when not overridden, provides sensible and predictable behavior for portable applications.
178
+
Application servers MUST provide a default mapping from group names to roles. That is, a caller who is a member of group "foo" is considered to have role "foo". This default mapping MAY be overridden by explicit proprietary configuration, but, when not overridden, provides sensible and predictable behavior for portable applications.
179
179
180
-
An application MAY provide a default mapping from caller principal names to roles. That is, a caller with the name "bar" is considered to have role "bar". This default mapping MAY be overridden by proprietary configuration.
180
+
An application server MAY provide a default mapping from caller principal names to roles. That is, a caller with the name "bar" is considered to have role "bar". This default mapping MAY be overridden by proprietary configuration.
0 commit comments