Frontend Implementation
Sequence
- In the above sequence diagram, we have depicted information related to frontend web application only.
- When the user opens the login screen, it is directed to a screen we prepared on the front web application with the Login to mIDentity or something similar.
- In our frontend implementations, this screen will be named as /callback page.
- The user can get to this screen in two ways, directly by /callback or /callback?code=code
- Here we need to check if the query parameter is a code value or not and then perform the required implementation.
By /callback
- We direct to this address when the user clicks on the Login to mIDentity button.
- What we need to perform here is to get the address, that the user will login to, from the backend application and then to redirect user to this address.
- Make a Request URL:
/auth/oidc
Request Method: GET
Parameter | Description | Type |
---|---|---|
redirect_uri | The address to return after a successful login | Query parameter |
- As a response we get an address from the backend application and when we redirect user on the frontend web application, the login process will start on mID Provider OpenID.
- This address comes as “Composed_url”. For example:
"composed_url":"https://tenantname.aws1.test1.com/auth/realms/{tenantname}/protocol/openid-connect/auth?client_id={client_id}&redirect_uri=https%3A%2F%2Foidcdebugger.com%2Fdebug&scope=openid&response_type=code%20token&response_mode=form_post&nonce=2wfzjk80tki"
By /callback?code=code
-
After the user clicked the Login to mIDentity button and successfully logged in, user gets back to this address. Here the code query parameter is set by the server, that provides us to login with OpenID.
-
The process will function when we read the code value from the query parameter and forward it to the backend application.
-
Make a request URL:
/auth/code
-
Encoding: x-www-form-urlencoded
-
Method: POST
Parameter | Description | Type |
---|---|---|
redirect_uri | The exact same address used to login | Body |
code | The code taken as a query parameter | Body |
-
The process is completed when the backend application gets the code value and the JWT token, session or information of the authentication process and other credentials of user.
-
The response:
{
"token":"eyJhbGciOiJSUzI1NiIsInR5cCIgOiAiSldUIiwia2lkIiA6ICJhY2tnTmFLcmJuZVIwc3NkZ0VWcWFGNHRCZHBCUGp1UVJLWC1faGRJbnhzIn0.eyJqdGkiOiJmMDY5MjFjNC0xOGU0LTQ3ZjYtOGUwZi03N2JjZjk5NzAwYjkiLCJleHAiOjE1OTIzMTAyODcsIm5iZiI6MCwiaWF0IjoxNTkyMzA5OTg3LCJpc3MiOiJodHRwczovL3Rlc3RpbmcuYXBpLm1pZC1pbnQtMDIu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