-
Notifications
You must be signed in to change notification settings - Fork 30
Api Key Authentication
sheldonabrown edited this page Jul 30, 2013
·
2 revisions
OneBusAway provides a convenient mechanism for authenticating and authorizing user requests.
At a high level it works like this:
- A user requests an API key from the specific agency
- An administrator from the agency generates and stores an API key in the OneBusAway user database (via the API Key Webservice ). The administrator delivers this API key to the user
- A user makes an HTTP request using this API key
- The system intercepts the request and verifies the API key is valid (if configured for this resource)
- The system ensures this key was not seen since a configurable interval
- This system processes the corresponding URL and returns the results
Read further if you are interested in the implementation of this mechanism.
- An HTTP request is made for a specific URL
- Struts dispatcher maps the URL to an internal resource
- Struts dispatcher evaluates and invokes any interceptors configured for this resource
- ApiKeyInterceptor is one of those configured interceptors. It is loaded an invoked
- ApiKeyInterceptor confirms that this resource requires authentication (Java annotations are used to indicate methods/webservices that explicitly require authentication)
- ApiKeyInterceptor looks for a key as a parameter
- ApiKeyInterceptor asks the KeyService if this key has access to the requested resource
- ApiKeyPermissionServiceImpl compares the key against keys in the database
- ApiKeyPermissionServiceImpl tests to see if the request using this key was made after a configurable wait period to protect resources
Should any of the above tests fail, access to the resource is denied.