Created
October 19, 2021 01:03
-
-
Save Centzilius/54021ee10d898cfb31587677f1b41956 to your computer and use it in GitHub Desktop.
Mattermost Auth Token extractor for MM + GitLab + LDAP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from requests import session | |
import re | |
username = "" | |
password = "" | |
gitlab_url = "https://gitlab.example.com" | |
mattermost_url = "https://mattermost.example.com" | |
sess = session() | |
csrf = re.search( | |
r'<meta name="csrf-token" content="([^"]+)" \/>', | |
sess.get(f"{gitlab_url}/users/sign_in").text | |
).groups()[0] | |
gitlab_login = sess.post( | |
f"{gitlab_url}/users/auth/ldapmain/callback", | |
data={ | |
"authenticity_token": csrf, | |
"username": username, | |
"password": password | |
} | |
) | |
sess.get(re.search( | |
r'window.location= "([^\"]+)', | |
sess.get(f"{mattermost_url}/oauth/gitlab/login").text | |
).groups()[0]) | |
print(sess.cookies["MMAUTHTOKEN"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment