christian-marie / oauth2-server

Haskell libraries for implementing OAuth2 servers.
Other
24 stars 7 forks source link

OAuth2 Server

Build Status

OAuth2 Server is a small web application which allows clients, users, and services to request, approve, and verify OAuth2 tokens.

The intended use case is a fleet of related, but not necessarily integrated, web services. Rather than integrate OAuth2 server functionality into each service (and giving each of them access to user authentication databases, etc.) we centralise user authentication and token management into a single OAuth2 Server.

Architecture

There are four roles involved in a deployment of OAuth2 Server:

Interactions between components

These interactions, at a high level, include:

  1. A user requests that a client perform some action with some service.

  2. If the client does not already have an appropriate token for the user, it requests one from the server.

  3. If required, the user reviews and approves the token request. The client should, if possible, store and reuse the token in subsequent requests.

  4. The client uses the token to make requests to the service.

  5. The service verifies the token with the server. This returns information about the token validity, owner, scope, etc.

  6. If the token is valid, the service responds to the request as appropriate according to its own policies.

Authentication

As OAuth2 Server is intended to be deployed in an environment where all services are centrally controlled, all parties are authenticated:

Security considerations

All interactions with OAuth2 Server itself and between the other parties contain sensitive information and MUST be protected with correctly configured TLS. All parties SHOULD validate the certificates used by the OAuth2 Server and by other parties.

Testing

If your environment is sufficiently like mine you can use the runit.sh script to setup a temporary database, run the server, and clean up.

Warning you must review the runit.sh script before you use it. It will drop your PostgreSQL databases without asking for confirmation!

# Run the server
./runit.sh &
# Run the tests
cabal build test-acceptance && \
./dist/build/test-acceptance/test-acceptance http://localhost:8080/