|
| 1 | +# Login |
| 2 | + |
| 3 | +## Authentication and authorization |
| 4 | + |
| 5 | +The authentication and authorization of a user have traditionally been performed in one step via the `ISPYBClient` hardware object. The authentication step has either been done through LDAP or delegated to ISPyB. `ISPYBClient` has been replaced by `ISPyBAbstractLIMS` and exists in two variants, one for user-based login (`UserTypeISPyBLims`) and another one for proposal (`ProposalTypeISPyBLims`) both of which support authentication via LDAP or ISPyB. The possibility to authenticate via LIMS will be removed in the future, and authentication has to be delegated to a process dedicated to authentication. The authorization for a user to use a beamline is performed via the user portal or LIMS system. |
| 6 | + |
| 7 | +### Authentication with single sign on |
| 8 | + |
| 9 | +MXCUBE can be configured to use Single sign-on (SSO) through OpenIDConnect for user authentication. The OpenIDConnect configuration is located in the `server.yaml` file, which should contain an `sso` section like the one below. |
| 10 | + |
| 11 | +``` |
| 12 | +sso: |
| 13 | + USE_SSO: false # True to use SSO false otherwise |
| 14 | + ISSUER: https://websso.[site].[com]/realms/[site]/ # OpenIDConnect issuer URI |
| 15 | + LOGOUT_URI: "" # OpenIDConnect logout URI |
| 16 | + TOKEN_INFO_URI: "" # OpenIDConnect token info URI |
| 17 | + CLIENT_SECRET: ASECRETKEY # OpenIDConnect client secret |
| 18 | + CLIENT_ID: mxcube # OpenIDConnect client ID |
| 19 | + SCOPE: openid email profile # OpenIDConnect defualt scopes, none scope is actually beeing used |
| 20 | + CODE_CHALLANGE_METHOD: S256 # OpenIDConnect challange method |
| 21 | +``` |
| 22 | + |
| 23 | +User authorization is delegated to the LIMS client inheriting `AbstractLims` and is performed in the `login` method. |
| 24 | + |
| 25 | +## HTTP Session management |
| 26 | + |
| 27 | +MXCuBE web sessions are meant to expire when there is no activity |
| 28 | + |
| 29 | +For this purpose: |
| 30 | + |
| 31 | +- Flask configuration setting `PERMANENT_SESSION_LIFETIME` is set |
| 32 | + to the preferred value (seconds). |
| 33 | + |
| 34 | +- Flask configuration setting `SESSION_REFRESH_EACH_REQUEST` is set, |
| 35 | + which is the default anyway. |
| 36 | + |
| 37 | +- Flask session setting `session.permanent` is set |
| 38 | + right after successful authentication. |
| 39 | + |
| 40 | +- The front-end calls the `/mxcube/api/v0.1/login/refresh_session` endpoint |
| 41 | + regularly (hardcoded value: 9000 milliseconds) |
| 42 | + for as long as the browser tab is open. |
| 43 | + |
| 44 | +Every time the _refresh_ endpoint is called, |
| 45 | +the browser session cookie is refreshed, |
| 46 | +meaning its expiration timestamp is pushed back in the future |
| 47 | +for as much as the value stored in `PERMANENT_SESSION_LIFETIME`. |
0 commit comments