Last active
April 7, 2021 21:39
-
-
Save hersoncruz/2b14dba094c86cff725d852933e52313 to your computer and use it in GitHub Desktop.
auth_token client example
This file contains 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 django.shortcuts import render | |
from django.http import HttpResponse, HttpResponseRedirect | |
import crypt | |
import time | |
def index(request): | |
return HttpResponse("<a href='/sso/go/'>Go to LMS</a>") | |
def go(request): | |
secret_salt = 'AUTH_TOKEN_SALT' | |
timestamp = str(time.time()) | |
user = 'USERNAME' | |
email = 'user@email.com' | |
newuser = str(1) | |
cohortname = '99999' | |
fn = 'FIRST_NAME' | |
ln = 'LAST_NAME' | |
city = 'CITY' | |
country = 'COUNTRY' | |
lmsurl = 'http://example.com' | |
payload = timestamp + user + email | |
token = crypt.crypt(payload, secret_salt) | |
url = lmsurl + '/auth/token/index.php' | |
sso_url = url + '?user=' + user + '&token=' + token + '×tamp=' + timestamp + '&email=' + email + '&newuser=' + newuser + '&cohortname=' + cohortname + '&fn=' + fn + '&ln=' + ln + '&city=' + city + '&country=' + country | |
return HttpResponseRedirect(sso_url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment