When configuring your API you can choose between different authentication methods, these are:
Basic/Digest Authentication
OAuth 2.0
JWT
We tried to design Janus in a way that the authentication provider are simple to setup and completely decoupled from the gateway.
Let's add an OAuth2 authentication to our endpoint.
1. Configure OAuth2
First of all let's configure our oAuth2 provider. This could be any OAuth2 provider: Google, Facebook, etc... Let's bring a container up with a mocked OAuth2 server:
The first thing is to give a name for the oAuth2 server.
Within oauth_endpoints we setup only one endpoint for this example, which is the token. If you look closely you will see that the oauth_endpoints.token is just a proxy configuration, exactly the same that we used to configure our first endpoint.
We've defined a token_strategy. Here you can choose between jwt or storage, storage means that Janus will be in charge of storing and managing (expiring, refreshing, etc) the tokens once they are returned from your oauth provider. JWT means that Janus will only check for expiration and secret of the tokens, but it wont store them.
This allows Janus to not go on the auth service on every single request to check the validity of the token.
If you want to check all available configurations for OAuth2 please visit this.
Now lets add this configuration to Janus:
http -v POST localhost:8081/oauth/servers "Authorization:Bearer yourToken" "Content-Type: application/json" < auth.json