Authentication and authorization are managed in common through most France-IOI applications, using the OAuth2 protocol. The authorization is centrally managed in the Login Module. The PHP clients share a lib which implement the OAuth2 client to Login Module: login-module-client.
The previous AlgoreaPlaform workflow and the different options are described in the working docs.
OAuth Login Workflow
The following workflow uses OAuth2 “authorization code” workflow which is the only one which now recommended for SPAs.
click "login"
Algorea Frontend
(SPA)
Algorea Backend
Login Module
GET /oauth/authorize?scope=account&state=<state>&response_type=code
&code_challenge=<code_challenge>&code_challenge_method=S256
&client_id=17&locale=fr&redirect_uri=urlencoded_SPA_return_urlredirect to login prompt
enter credentials, consent, ...
302 redirect to https://spa_url?code=...&state=... + set session cookie
POST https://backend/auth/token
with code, code_verifier
access_token, expire_in
POST https://login-module/oauth/token
with code, code_verifier, server secret
with code, code_verifier, server secret
{access token:..., refresh_token:...,
expires_in: 3600, type: bearer, scope: null }
expires_in: 3600, type: bearer, scope: null }
check credentials,
store consent
generate authorization code
update (or create) user
store access_token & refresh_token
store access_token
user info
GET /user_api/account
user info
GET /current-user/
Generate:
- state: a random 32-byte string (->store it)
- code_verifier**: a random 32-byte string (->store it)
- code_challenge**: sha256(code_verifier)
(all base-64 encoded with +,/,= replaced)
(** requires login-module to support PKCE)
update user info in UI
Extract code & state
Verify state
redirect
User Agent
Logout Workflow
click "logout"
Algorea Frontend
Algorea Backend
Login Module
logout request
(using cookie)
(using cookie)
ok + clear session cookie
clear all tokens
clear session cookie
clear session cookie
auth popup
POST /auth/logout
(using access-token)
(using access-token)
access_token, expiry_in
store access_token
POST /auth/temp_user
clear all access_token & refresh_token for the user
clear access_token
clear UI from user info
clear UI from user info
(may contact all servers to
notify the removal of session)
notify the removal of session)
Token Refresh
Algorea Frontend
Algorea Backend
Login Module
POST /oauth/token
with refresh-token
with refresh-token
new_access_token
gen new access_token
POST /auth/token
(using existing_access_token)
(using existing_access_token)
access_token, expiry_in
validate the token, fetch the refresh token
update access_token
only keep existing_access_token and
new_access_token as access token for this user
new_access_token as access token for this user
existing_access_token expires in less than 5min!