Search code examples
apisingle-sign-onaccess-token

Single Signon Tokens usage in multiple applications


I am currently working on a small SingleSignon application. This way, I can save time whenever i make a new project, because the login process is mostly in place from the beginning. To start with i think I should mention that many off my applications are build on Angular, so I often have multiple applications in one project:

  • The Angular app (HTML / Javascript)

  • The REST API (Either PHP or .NET (doesnt really matter))

I have been reading up on OAuth2, JWT and so on, and I understand that:

1) the application authorizes with the SSO API.

2) the SSO API responds (if successful) with an access token.

3) Add the access token to the header, and i have now access to the SSO APIs

BUT

What about my own API that belongs to the application itself? (See the image below for better understanding). The API for the application knows nothing about the token I recieved from the SSO API, and would of course reject it...

SingleSignon Authorization flow

How would you normally implement this? Should the application API also ask the SSO api on every request, to validate the token, or how? What would be best practice?`

Thanks /Dennis


Solution

  • After studying Auth0, I found out that if you are using Opaque tokens (croptographically random string, with no meaning), the token is being verified against the authorization server from the API, as I mentioned in my original post. If you are using JsonWebToken on the other hand, there is no need to contact the authorization server, but check validity of the token by its expiration and signature, AND audience should match the domain of the custom API

    So therefore; If you have a custom resource / API, you can benefit from a selfsigned token like JWT, and define the custom resource url in the AUD grant of the token. Then the resource can validate against the AUD grant.