mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
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
13 lines
440 B
Python
13 lines
440 B
Python
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'))
|