[CONF] Apache CXF Documentation Standardized Authentication / Authorization

2014-07-10 Thread Christian Schneider (Confluence)














  


Christian Schneider edited the page:
 


Standardized Authentication / Authorization   






  
  
  



 Info




Ideas / Proposal




CXF already supports a wide range of authentication and authorization approaches. Unfortunately they are all configured differently and do not integrate well with each other.
...
An XACML policy enforcement point can retrieve the JAAS login data and do authorization against an XACML Policy Decision Point (PDP).
 Separating Authorization from CXF 
 As authorization is not only relevant for webservices it makes sense to keep the authorization code separate from cxf too. So one way to implement authorization would be to put it into a blueprint extension. Of course this would cover only OSGi and blueprint but it would be a start. 
 It could work similar to the XA transaction support. Unlike in tx support we could scan all beans for security annotations like @RolesAllowed. Then for each bean that has this annotation we could proxy it with a class that does the security check. This would allow to have minimal xml configuration. 
 Another approach is to mark beans for security checks using xml like in tx support. This variant then would also work nicely for XACML authorization as in that case there would be no annotation to scan for. 
Karaf role based OSGi service Authorization
Karaf 3 already supports authorization on the OSGi service level and uses JAAS for authentication. So if we do a JAAS login in CXF and the service impl code calls an OSGi service then the Karaf role based securtiy should already work out of the box.We could add annotation based Authorization to karaf code to make it even better and require less config. 
Exception handling and answer generation
...

Failure at Authentication: javax.security.auth.login.LoginException could also be more specific like AccountLockedException
Failure at Authorization: org.apache.cxf.interceptor.security.AccessDeniedException or java.security.AccessControlException. The later one is better for code separate from cxf as it does not depend on CXF. 

Then in the transport like the http transport we map the exception to the defined status code and http response:

 

[CONF] Apache CXF Documentation Standardized Authentication / Authorization

2014-07-08 Thread Christian Schneider (Confluence)














  


Christian Schneider hat eine Seite erstellt:
 


Standardized Authentication / Authorization   






Icon

 Ideas / Proposal



CXF already supports a wide range of authentication and authorization approaches. Unfortunately they are all configured differently and do not integrate well with each other.
So the idea is to create one standardized authentication / authorization flow in CXF where the modules can then fit in. There are a lot of security frameworks out there that could be used as a basis for this. The problem is though that each framework (like Shiro or Spring Security) uses its own mechanisms which are not standardized. So by choosing one framework we would force our users to depend on this.
The best standardized security framework in java is JAAS. It is already included in Java and most security frameworks can be hooked into it. So lets investigate what we could do with JAAS.
Authentication using JAAS
JAAS authentication is done by creating a LoginContext and doing a login on it. Things to configure is the name of the login config and the Callback Handlers. So CXF needs mechanisms for the user to set the config name and needs to provide CallBackHandlers to supply credentials.
CallbackHandlers
CXF needs to supply different data to identify the users depending on the chosen authentication variant.
Basic Auth: username and password from HTTP header
WS-Security UserNameToken: Username and password from SOAP header
Spnego: Kerberos token from HTTP header
HTTPS client cert: Certificate information
We could simply detect what information is provided and configure the Callbackhandlers for each variant.
JAAS configuration
The JAAS configuration is supplied differently depending on the runtime CXF runs in.
Standalone: For standalone usage the JAAS config can simply come from a file.
Servlet Container: Not sure. Is there a standard approach for this?
Apache Karaf: Karaf already provides a JAAS integration so we just have to configure the JAAS config name and supply a suitable config in karaf
Supplying Role and User information
JAAS stores identity information in the JAAS subject. The method getPrincipals returns Principal objects which can be users, roles or even other identity information. To differentiate between roles and users there are two common approaches.

different Classes like a UserPrincipal or RolePrincipal. Unfortunately there are no standard interfaces
prefixes. So for example roles start with role- . Again there is no standard

Authorization
  

[CONF] Apache CXF Documentation Standardized Authentication / Authorization

2014-07-08 Thread Christian Schneider (Confluence)














  


Christian Schneider bearbeitete die Seite:
 


Standardized Authentication / Authorization   






...
We could simply detect what information is provided and configure the Callbackhandlers for each variant.information we can supply. Depending on when the login should happen we could collect CallbackHandlers in the Message using Interceptors. 
JAAS configuration
The JAAS configuration is supplied differently depending on the runtime CXF runs in.
...

different Classes like a UserPrincipal or RolePrincipal. Unfortunately there are no standard interfacesThere seems to be a Group interface which allows to differentiate between Users and Groups and also allows to see group members. 
prefixes. So for example roles start with role- . Again there There is no standard for this approach 

Authorization
Authorization has very diverse requirements. So we need to make sure we integrate well with different approaches.
...
Karaf 3 already supports authorization on the OSGi service level and uses JAAS for authentication. So if we do a JAAS login in CXF and the service impl code calls an OSGi service then the Karaf role based securtiy should already work out of the box.
 Exception handling and answer generation 
 Currently the authentication and athorization modules often also generate the answer to the caller. It might be a good idea to decouple this. 
 In the authentication and authorization we only throw a defined Exception: 

 Failure at Authentication: javax.security.auth.login.LoginException could also be more specific like AccountLockedException 
 Failure at Authorization: org.apache.cxf.interceptor.security.AccessDeniedException or java.security.AccessControlException 

 Then in the transport like the http transport we map the exception to the defined status code and http response: 

 LoginException: HTTP Code 401 
 AccessDeniedException, AccessControlException: HTTP Code 403 

Karaf integration
Ideally we should integrate the new authentication / authorization model in a way that enable the user to switch on authentication for the karaf server without specific configurations in the user bundles that implement the services.
...
Doing a full JAAS login requires to use subject.doAs to populate the AcessControlContext. This is not possible in a CXF interceptor as the interceptor only works on a message but can not call the next interceptor for doAs. So the question is where to do the JAAS login and the