-
Notifications
You must be signed in to change notification settings - Fork 57
How it works?
Aitor Magán García edited this page Jul 21, 2014
·
1 revision
- If the user tries to perform a log in and it's not currently logged in, a 401 exception is raised by the
loginfunction of theplugin.pyfile. Under this circumstances, is the functionchallengecalled. This function will only redirect the user to the OAuth2 Server log in page when a login attempt is performed. Thechallengefunction ignores the 401 exceptions raised because the user doesn't have grants to perform an operation. - Once that the user completes the log in, he or she is redirected to the page
/oauth2/callbackof the CKAN instance. In this case, theidentifyfunction of therepozewho.pyfile captures the request and tries to get the OAuth2 token. If the operation can be performed without exceptions, theauthenticatefunction will be executed with the value returned by theidentifyfunction. Otherwise, a message error will be shown. - The
authenticatefunction should return the user identifier. To do so, the function asks for the basic user information to the OAuth2 server with the token returned by theidentifyfunction. Once that the user identifier is got, the user model is asked for that user. If the user does not exist, it's created. Otherwise, the user is updated. Finally the function returns the user identifier. - Then, the
rememberfunction is called to set the cookies that allow the system to identify the user without performing another login attempt. - The
identifyfunction of theplugin.pyfile read the propertyrepoze.who.identityfrom the request environ. This variable is automatically set using the cookies stored by the authenticate process explained above. If the user is logged, this variable contains the user identifier. In this case, the variabletoolkit.c.useris set to the user identifier. Otherwise, the variable is set to None.