cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Piotr Klimczak (JIRA)" <>
Subject [jira] [Commented] (CXF-5118) Create CXF interceptor which will use HTTPS client certificates to create JAAS SecurityContext
Date Wed, 06 Aug 2014 18:18:13 GMT


Piotr Klimczak commented on CXF-5118:

Well I am not JAAS expert too.
But LoginModules are only part of this standard. Simply note that authorisation is done later.
Not in LoginModule.

So my last commit is actually not avoiding JAAS at all. It is just opposite as username extracted
from certificate and possible roles provided by user are then running in java security context
in very same way as JAASLoginInterceptor would do AFTER login.
It was designed to work altogether with other JAAS aware interceptors, like the one to do
annotation authorisation stuff with @RolesAllowed which is a part of java security framework.

In reference to TLSLoginToken, please note that TLSAuthenticationInterceptor creates standard
CXF LoginSecurityContext in Message with username extracted from certificate. So it is already
working as a basic TLSLoginToken, that could be handled for example by JAASLoginInterceptor.
But with my last example, JAASLoginInterceptor can be avoided at all.
Please note, that TLSSecuritySubjectProvider expects to receive Subject, which is provided
for example by JAAS LoginModules. So user can write mapping functionality and simply do JAAS
login as he want to, with context which he chose to.

Example of avoiding JAASLoginInterfceptor at all.
All we have to do is to write proper implementation of introduced TLSSecuritySubjectProvider
public class MySecuritySubjectProvider extends TLSSecuritySubjectProvider {
	private String getPassword(String username) {
		return "someMappedPassword";

	Subject getSubject(String userName, X509Certificate certificate)
			throws SecurityException {
		String password = getPassword(userName);
		CallbackHandler handler = new NamePasswordCallbackHandler(name, password);
		LoginContext ctx = new LoginContext(getContextName(), handler);

		return ctx.getSubject();

Doesn't look complicated isn't it.

For user provided roles implementations may look like:
public class MySecuritySubjectProvider extends TLSSecuritySubjectProvider {

	private List<String> getRoles(String username) {
		//Get roles from somewhere
		return new ArrayList<String>();

	Subject getSubject(String userName, X509Certificate certificate)
			throws SecurityException {
		return createSubject(userName, getRoles(userName));

Simple too.

As I said before- in both cases TLSAuthenticationInterceptor runs further interceptors in
subject context (java security context) providing security context to work with JAAS authorisation
So TLSAuthenticationInterceptor is not avoiding JAAS. It is directly opposite as it is working
very well with JAAS.

> Create CXF interceptor which will use HTTPS client certificates to create JAAS SecurityContext

> -----------------------------------------------------------------------------------------------
>                 Key: CXF-5118
>                 URL:
>             Project: CXF
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Sergey Beryozkin
>            Assignee: Christian Schneider
> Use case:
> The user authenticates against the webservice using an X509 client certificate. In case
of successful authentication the JAAS security context should be populated with a Subject
that stores the user name and the roles of the user. This is necessary to support Authorization
at a later stage.
> Design ideas
> The SSL transport will be configured to only accept certain client certificates. So we
can assume that the interceptor does not have to do a real authentication. Instead it has
to map from the subjectDN of the certificate to the user name and then lookup the roles of
that user. Both then has to be stored in the subject's principles.
> The mapping could be done inside a JAASLoginModule or before. Inside will give the user
more flexibility.
> The next step to retrieve the roles should be done in one of the standard JAASLoginModules
as the source of the roles can be quite diverse. So for example the LdapLoginModule allows
to retrieve the roles from Ldap. At the moment these modules require the password of the user
though which is not available when doing a cert based auth.
> So I see two variants to retrieve the roles:
> 1. Change the loginmodules like the LDAP one to be configureable to use a fixed ldap
user for the ldap connect and not require the user password. So the module would have two
modes: a) normal authentication and group gathering b) use a fixed user to just retrieve roles
for a given user
> 2. Store the user password somewhere (e.g. in the mapping file). In this case the existing
LDAPLoginModule could be used but the user password would be openly in a text file
> 3. Create new LoginModules with the desired behaviour (fixed user and only lookup of

This message was sent by Atlassian JIRA

View raw message