This project contains boilerplate code necessary for using the authservice pluggable user administration service.
To verify that this code will run in you karaf instance:
- Clone and build this project:
git clone https://github.com/steinarb/authservice-sampleclient cd authservice-sampleclient mvn clean install
- from the karaf console, install the authservice prerequisite
feature:repo-add mvn:no.priv.bang.authservice/karaf/LATEST/xml/features feature:install user-admin-with-testdb
- From the karaf console install the authservice sample client project
feature:repo-add mvn:no.priv.bang.authservice/authservice.sampleclient/LATEST/xml/features feature:install authservice-sampleclient
- Open the URL http://localhost:8181/sampleauthserviceclient in a web browser
- In the login page that opens, log in with username admin and password admin
- Try visiting the “Admin page (requires the useradmin role)” link and verify that it allowed
- Click on the “Back to the top” link
- Click on the “Log out (will redirect to the login page)” link (which will redirect to the login page)
- Log in with username jad and password 1ad
- Verify that this user does not have access to the admin page
This procedure assumes that your webapp project is a multimodule maven build.
- Clone this project, remove the .git directory from the clone
- Move the cloned project to the level of the modules in your multimodule build
- Change the POM to fit in:
- Change the groupId to match your project
- Change the artifactId to match the groupId (maven-bundle-plugin is happiest when the last segment of the groupId matches the first part of the artifactId. The bundle name and the default package will become groupId+artifactId but with only a single copy of the last part of groupId and first part of the artifactId)
- (Not strictly necessary) Make your parent POM be the parent of the project
- (If you set a parent) Remove the <version>
- Add the new module to <modules> in your top POM
- Change the HTTP_WHITEBOARD_CONTEXT_PATH in AuthserviceSampleClientServletContextHelper to what your webapp’s context path to be
- change the src/main/resource/shiro.ini to limit access to sub-paths of your webapp (e.g. by using pairs of roles and paths like the configuration for the /admin path)
- (Not strictly necessary but more aesthetically pleasing) change the HTTP_WHITEBOARD_CONTEXT_NAME to something more appropriate to the path, and change all other usages (in this project AuthserviceSampleClientShiroFilter and AuthserviceSampleClientServlet)
You can change the name of the classes to be more appropriate, but that doesn’t have any other effect than aesthetics. No classes are exported from the bundle.
The license of this karaf feature, is Apache Public License v 2.0
See the LICENSE file for details.