Software licensing: Authentication and authorization for admin pages
For simplicity and security I’ve decided to integrate with the Google Account authentication mechanism that’s built into Google App Engine. This allows anyone with a Google account to login to my application without the need to setup another account. This also gives me access to the user’s valid email in order to send messages and other communication related to the service I provide.
http://domain/ http://domain/api/ http://domain/admin/
The API will require authentication with each call in the form of an apikey (may change to oAuth in the future). I was able to secure the admin area of the site by adding a security-constraint to the web.xml file. Here’s what that looks like.
1 2 3 4 5 6 7 8 9 10 11
<web-app ...> ... <security-constraint> <web-resource-collection> <url-pattern>/admin/*</url-pattern> </web-resource-collection> <auth-constraint> <role-name>*</role-name> </auth-constraint> </security-constraint> </web-app>
You might have noticed this mechanism is not limited to authentication only. It’s also possible to include authorization preferences by role using role-name.