Single sign-on (SSO) / Single sign-on tutorial |
Prevent direct access to the application and force the end user to enter a login and password.
<EXECUTION> <PATH>$(res.path)</PATH> <MODULE>myApp.42r</MODULE> <DELEGATE service="services/SimpleSSOServiceProvider"> </DELEGATE> </EXECUTION>In this example, “SimpleSSOServiceProvider” corresponds to the configuration file of your service, that should be located by default in $FGLDIR/web_utilities/services.
<EXECUTION> <PATH>$(res.path.fgldir.services)/simplesso/bin</PATH> <MODULE>SSOService.42r</MODULE> </EXECUTION>Make your service configuration point on your service executable. In this example, that is SSOService.42r.
Figure 1. Application URL
The HTTP incoming request is now handled by the Genero service. It checks the existence of a valid cookie (step 2 of the workflow) and analyzes the URL query string parameters in order to find values for the login/password. As this is the first start, there is no existing valid cookie (step 3b of the workflow) and the query string is null as there is not yet a submit from the login page (step 4 on the workflow). As a result, the connection is refused and the user is directed by the service to a login XHTML page:
Figure 2. Login page
CALL parseQueryString(query) RETURNING user, pwd, userQueryString, isCookie
Once user and password have been retrieved from the query string, the service checks to see whether the username and password are valid.
If the username and password are valid, the application can be started. The Genero REST service returns the HTTP code 307 and the description _GENERO_INTERNAL_DELEGATE_ to notify the dispatcher to start the application as response to current user-agent request.In addition, if the username and password have a match, a new cookie is sent to the browser. An instantaneous redirection is done, this valid cookie is checked by the service (it returns to step 2 of the workflow) and the connection is accepted (step 3a of the workflow). The next time the user starts the application, the 4GL service will check the validity of this cookie. According to the cookie's expiration, the application may start automatically without requiring the user logging in again or returning a new login page.
If the username and password do not match, the user is redirected to a login page with a 403 error.