Search code examples
pythonckan

Is there any function to do login action in CKAN without API call


Ideally how login works in CKAN as per who.ini configuration and code is:

[plugin:friendlyform]
use = ckan.lib.repoze_plugins.friendly_form:FriendlyFormPlugin
login_form_url= /user/login
login_handler_path = /login_generic

Here login_handler_path is responsible for login and in frontend side of CKAN, it makes POST request to /login_generic endpoint with name as username and password.

Right now I am trying to create one plugin, where I am trying to login via plugin itself (with some function) without having user to login via any form in frontend.

So is there any helper / action function which I can use so that I can login behind the scenes in CKAN plugin itself.

What I understand is that CKAN uses some repoze cookie / API Headers to identify if user is logged in or not. If I make use of normal POST requests in python code, then I won't be able to set these cookies or environment variables and if I try to do it manually then I fear it will break something.

Any help is much appreciated


Solution

  • If I understood your question correctly, I think you should try to use IAuthFunctions to override CKAN's built-in authentication. This interface allows custom authentication methods to be integrated into CKAN.