I'm working on understanding Undertow's auth mechanisms a little better, and I'm looking at some code written by another developer that implements basic auth for all requests on a server. I'm a little confused by the difference between the login config and the AuthenticationMechanismsHandler and how they are different. I'm unclear if they are meant to be used together or if their functionality overlaps, etc.
I see code like this where I can set up one or more auth mechanisms via the loginConfig class and then I pass an identity manager to the DeploymentInfo.
LoginConfig loginConfig = new LoginConfig(realm);
Map<String, String> props = new HashMap<>();
props.put("charset", "ISO_8859_1");
props.put("user-agent-charsets", "Chrome,UTF-8,OPR,UTF-8");
loginConfig.addFirstAuthMethod(new AuthMethodConfig("BASIC", props));
servletBuilder.setIdentityManager(this).setLoginConfig(loginConfig);
Elsewhere I see what feels like nearly the same thing but via a different set of classes, where a number of auth handlers are added to the security inituial handler. Again, I can add one or more auth mechanism as well as passing in the identity manager:
handler = new AuthenticationCallHandler(handler);
handler = new AuthenticationConstraintHandler(handler);
final List<AuthenticationMechanism> mechanisms = Collections.<AuthenticationMechanism>singletonList(new BasicAuthenticationMechanism(realm));
handler = new AuthenticationMechanismsHandler(handler, mechanisms);
handler = new SecurityInitialHandler(AuthenticationMode.PRO_ACTIVE, this, handler);
What is the difference between these two approaches? Are they meant to be used together? Mutually exclusive? The loginConfig classes are covered in this part of the docs
but no mention at all is made of the handlers in my second code block.
Thanks!
~Brad
Developer Advocate
Ortus Solutions, Corp