Vaelor/python-mattermost-driver

Gitlab LDAP login

Closed this issue · 3 comments

hello

Thank you for your giving great useful OSS for mattermost.

I'm using mattermost with Gitlab-LDAP authentication.
I'd like to use this driver with Gitlab-LDAP account instead of mattermost standard account.

Is there somehow I can use this driver through Gitlab-LDAP login ?

I can get tokens & cookies from python requests module as below.

#######################################
session = requests.session()

get_auth_token = session.get(mm+'/oauth/gitlab/login')

pq_auth_token = pq(get_auth_token.content)
csrf_token = pq_auth_token('#new_ldap_user input[name="authenticity_token"]')[0].value

payload = {'authenticity_token': csrf_token, 'username': userid, 'password': password}

ldap_login = session.post(
gitlab + '/users/auth/ldapmain/callback',
data=payload,
)

for i,ldap_history in enumerate(ldap_login.history):
if i == 2:
authenticated_response = ldap_history

mm_cookie = authenticated_response.cookies
#######################################

Thank you.

Currently on the go, sorry for the short reply!
Just a suggestion for the moment: Wouldn't a token work too? This way it doesn't matter which login you normally use in mattermost.

Thank you for your quick response.

It worked!!
I just have taken mistake for getting token :(

Thank you.

Glad to hear! :-) If there is another Problem let me know!