Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Role based security for OSGi

I am searching for a security framework that allows role based security for OSGi services as well as CXF webservices. Some time ago I already used spring security but as we now switched to blueprint it is not an option anymore as far as I understood. To configure the access rules I would like to mainly use the standard @RolesAllowed annotation. So what are my best starting points? I also thought about implementing this myself as a blueprint extension but I would prefer an existing solution.

like image 494
Christian Schneider Avatar asked Mar 31 '13 11:03

Christian Schneider


Video Answer


2 Answers

I would suggest you go with Apache Shiro instead, http://shiro.apache.org/ .

It provides easy API's for authentication, authorization, cryptography, and session management. It can also be easily deployed inside a OSGI container. Some pros of Apache Shiro are listed here Apache Shiro vs Java EE native APIs

like image 54
Ashay Batwal Avatar answered Nov 02 '22 23:11

Ashay Batwal


In the mean time I created a blueprint extension for authorization based on JAAS and Java EE annoations (@RolesAllowed, @PermitAll, @DenyAll). You can add the extension to any blueprint file. It will then scan all beans for these annoations and intercept calls if they are found. It uses an existing JAAS context to get the roles of the user.

So prerequisite for this is doing a JAAS login. I have also created a CXF JAASAuthentication feature that logs in a user based on basic auth or ws security username principal. The module works together with the Apache Karaf JAAS support. So all karaf users and roles apply.

I will create a tutorial to show how to use all of this once the aries blueprint release that includes the authorization module is out. In the mean time I would be happy if you try it out and report any problems you have.

Btw. another approach for karaf is the role based access control for OSGi services that is built into karaf 3+. It does not work with annotations but is also easy to use. See http://coderthoughts.blogspot.de/2013/10/role-based-access-control-for-karaf.html

like image 25
Christian Schneider Avatar answered Nov 03 '22 00:11

Christian Schneider