Which page applies to my app? This page covers every application that logs users in through a login page in a browser: web apps, single-page apps, and also mobile and desktop apps that open the system browser for the login. Only for constrained devices that can't easily open a browser and show their own login screens (embedded login), see Native. For back-ends calling APIs on their own behalf, see Machine (M2M).
In this setup you connect your app to Quasr using OpenID Connect and use a web-hosted login page. OpenID Connect is an Internet standard for identity federation, meaning it allows your apps to use a centralized identity provider. The standard builds upon OAuth 2.0 which is relevant for API access control. Hence it combines both identity and access control for your apps.
Don't worry it's an easy standard, in short:
Your app redirects to the authorization endpoint on Quasr which triggers the login.
Your user signs up or logs in using a web-hosted login page (either ours or yours).
When finished Quasr redirects back to your application with tokens, both an identity and an access token. Both tokens are signed JWT tokens. Your application can consume the identity token to learn about the user; the acces token you can use towards your backend APIs.
This setup is highly recommended whenever possible as it will give a smooth, secure and standard integration. Hence it's suitable for:
web applications - with or without BFF
mobile applications - with or without BFF
desktop applications - with or without BFF
Detailed Flow
The sequence diagram below details the entire flow.
You can easily get started with Quasr using the Hosted Login UI and by connecting your app using OAuth 2.0 / OpenID Connect 1.0. If you're not already familiar please visit https://oauth.net/. In this section we'll just explain the basics to get started.
We recommend you use a standard OAuth 2.0 / OpenID Connect 1.0 library or module for your chosen application framework. Some sources:
Be mindful using other open-source libraries, or building your own using partial libraries (JWT), you could introduce undesired security issues. Best to always use expert-vetted libraries that comply with standard.
High-level the process is as follows:
Your application requests authorization from Quasr and is redirected to the Hosted Login UI.
The user signs up or logs in on the Hosted Login UI and once finished will be redirected back to a specific return URL in your application.
Your application receives an ID token and/or an authorization code. The ID token is a JWT and can be used by your application to personalise the experience (it contains the user ID and can contain various personal attributes such as name). The authorization code can be exchanged.
If desired your application can exchange the authorization code for an access token (and also an ID token if the scope contains openid, and a refresh token if it contains offline_access). The access token is also a JWT and can be used to access Quasr, and/or your own API backend.
1A scope: lets the application use it on the user's behalf
2A claim: shares this personal data (attribute) with the application
Only request a refresh token (offline_access) if your app can store it safely: in your back-end (BFF), or in OS secure storage (e.g. Keychain, Keystore, Credential Manager) for mobile and desktop apps. Single-page apps without a back-end shouldn't request one, as browser storage isn't safe enough for long-lived tokens; start a new authorization request when the access token expires instead. See Tokens — Refresh.
The initial call is a GET request to https://{tenant_id}.api.quasr.io/oauth2/authorize with following parameters and if successful results in redirect to the hosted login page (302 Found):
client_id* - the (account) ID of the client
response_type* - code or id_token (if unsure choose id_token)
scope - requested scopes (space-separated)
state - application state (mechanism to pass state from your application through the flow)
As we align with OAuth 2.1 we require Proof Key for Code Exchange (PKCE) which means that your application will need to generate a unique key (code_challenge) for every request and include this in either clear (plain) or hashed format (S256) in the initial call to the authorize endpoint. Subsequently when you're exchanging the authorization code for tokens you must now also provide this key in clear text as validation.
Custom Login UI
Your application connects the same way when you use your own login UI instead of ours: only the login page in the middle of the flow changes, through the Login URI of the application. See Interfaces — Custom UIs for how to build one.