Rename auth functions to wiki auth functions

This commit is contained in:
Tanner Collin 2021-09-04 23:29:39 +00:00
parent 30b1488a18
commit 8f0b278dd4
3 changed files with 10 additions and 11 deletions

View File

@ -564,7 +564,7 @@ class MyPasswordChangeSerializer(PasswordChangeSerializer):
)
if utils_auth.is_configured():
if utils_auth.set_password(data) != 200:
if utils_auth.set_wiki_password(data) != 200:
msg = 'Problem connecting to Auth server: set.'
utils.alert_tanner(msg)
logger.info(msg)
@ -605,7 +605,7 @@ class MyPasswordResetConfirmSerializer(PasswordResetConfirmSerializer):
)
if utils_auth.is_configured():
if utils_auth.set_password(data) != 200:
if utils_auth.set_wiki_password(data) != 200:
msg = 'Problem connecting to Auth server: set.'
utils.alert_tanner(msg)
logger.info(msg)
@ -657,6 +657,6 @@ class SpaceportAuthSerializer(LoginSerializer):
if result:
data = self.context['request'].data
utils_auth.set_password(data)
utils_auth.set_wiki_password(data)
return result

View File

@ -6,23 +6,22 @@ import requests
from apiserver import secrets
from apiserver.api import utils
def is_configured():
return bool(secrets.AUTH_API_URL and secrets.AUTH_API_KEY)
def wiki_is_configured():
return bool(secrets.WIKI_AUTH_API_URL and secrets.AUTH_API_KEY)
def auth_api(route, data):
def auth_api(url, data):
try:
headers = {'Authorization': 'Token ' + secrets.AUTH_API_KEY}
url = secrets.AUTH_API_URL + route
r = requests.post(url, data=data, headers=headers, timeout=3)
return r.status_code
except BaseException as e:
logger.error('Auth {} - {} - {}'.format(url, e.__class__.__name__, str(e)))
return None
def set_password(data):
def set_wiki_password(data):
auth_data = dict(
username=data['username'],
password=data['password'],
)
return auth_api('set-password', auth_data)
return auth_api(secrets.WIKI_AUTH_API_URL + 'set-wiki-password', auth_data)

View File

@ -40,10 +40,10 @@ LDAP_API_URL = ''
# spaceport/ldapserver/secrets.py
LDAP_API_KEY = ''
# Auth API url
# Wiki Auth API url
# should contain the IP and port of the script and machine connected over VPN
# with trailing slash
AUTH_API_URL = ''
WIKI_AUTH_API_URL = ''
# Auth API key
# should be equal to the auth token value set in