[ 
https://issues.apache.org/jira/browse/AIRFLOW-1021?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16505365#comment-16505365
 ] 

ASF subversion and git services commented on AIRFLOW-1021:
----------------------------------------------------------

Commit 9c67ee84296b649ccb998e5b85187b956df9a757 in incubator-airflow's branch 
refs/heads/master from Alan Ma
[ https://git-wip-us.apache.org/repos/asf?p=incubator-airflow.git;h=9c67ee8 ]

[AIRFLOW-1021] Fix double login for new users with LDAP

By adding the new user to the session and commit
before merging, the correct user is returned by
`load_user(userid)` instead of `None` due to no
`id` assoicated with that user.

Closes #2778 from wolfier/AIRFLOW-1021


> Double logging required for new users with LDAP
> -----------------------------------------------
>
>                 Key: AIRFLOW-1021
>                 URL: https://issues.apache.org/jira/browse/AIRFLOW-1021
>             Project: Apache Airflow
>          Issue Type: Bug
>          Components: contrib
>    Affects Versions: Airflow 1.8
>            Reporter: Marcelo G. Almiron
>            Assignee: Alan Ma
>            Priority: Major
>
> Every user needs to login twice to access Airflow for the first time with 
> LDAP. 
> In the first trial the user is not persistent, so there is no `id` 
> associated, which leads to `None` value returned by `load_user(userid)`, 
> since `userid` is none `None`.
> A quick fix is to add the new user to the session and commit before merging.  
> That is, in module `airflow/contrib/auth/backends/ldap_auth.py`,  we can 
> change
> ```
> if not user:
>     user = models.User(
>         username=username,
>         is_superuser=False)
> session.merge(user)
> session.commit()
> flask_login.login_user(LdapUser(user))
> ```
> by
> ```
> if not user:
>     user = models.User(
>         username=username,
>         is_superuser=False)
>     session.add(user)
>             
> session.commit()
> session.merge(user)
> flask_login.login_user(LdapUser(user))
> ```



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to