mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 23:41:17 -05:00
refactor authentication code
moved api_key secret manipulation (generating and getting) into authentiation/utils, and added a property on the model, to facilitate easier matching of authenticated requests and the api keys they used
This commit is contained in:
12
app/authentication/utils.py
Normal file
12
app/authentication/utils.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from flask import current_app
|
||||
from itsdangerous import URLSafeSerializer
|
||||
|
||||
|
||||
def get_secret(secret):
|
||||
serializer = URLSafeSerializer(current_app.config.get('SECRET_KEY'))
|
||||
return serializer.loads(secret, salt=current_app.config.get('DANGEROUS_SALT'))
|
||||
|
||||
|
||||
def generate_secret(token):
|
||||
serializer = URLSafeSerializer(current_app.config.get('SECRET_KEY'))
|
||||
return serializer.dumps(str(token), current_app.config.get('DANGEROUS_SALT'))
|
||||
Reference in New Issue
Block a user