mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-04 00:00:27 -04:00
Refactor ApiKeys.secret and ServiceInboundApi.bearer_token to use the same encryption method and get rid of the duplicate code.
This commit is contained in:
@@ -73,7 +73,7 @@ def requires_auth():
|
||||
|
||||
for api_key in service.api_keys:
|
||||
try:
|
||||
get_decode_errors(auth_token, api_key.unsigned_secret)
|
||||
get_decode_errors(auth_token, api_key.secret)
|
||||
except TokenDecodeError:
|
||||
continue
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
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