mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Ideally all the primary keys in the db would be UUID in order to guarantee unique ids across distributed dbs. This updates the services.id to a UUID. All the tables with a foreign key to the services.id are also updated. The endpoints no longer state a data type of the <service_id> path param. All the tests are updated to reflect this update. The thing to pay attention to is the 0011_uuid_service_id.py migration script. This commit must go with a commit on the notifications_admin app to keep things working. There will be a small outage until both deploys have happened.
30 lines
967 B
Python
30 lines
967 B
Python
from flask import current_app
|
|
from client.authentication import create_jwt_token
|
|
|
|
from app.dao.api_key_dao import get_unsigned_secrets
|
|
|
|
|
|
def create_authorization_header(path, method, request_body=None, service_id=None):
|
|
if service_id:
|
|
client_id = str(service_id)
|
|
secret = get_unsigned_secrets(service_id)[0]
|
|
else:
|
|
client_id = current_app.config.get('ADMIN_CLIENT_USER_NAME')
|
|
secret = current_app.config.get('ADMIN_CLIENT_SECRET')
|
|
|
|
if request_body:
|
|
token = create_jwt_token(
|
|
request_method=method,
|
|
request_path=path,
|
|
secret=secret,
|
|
client_id=client_id,
|
|
request_body=request_body)
|
|
|
|
else:
|
|
token = create_jwt_token(request_method=method,
|
|
request_path=path,
|
|
secret=secret,
|
|
client_id=client_id)
|
|
|
|
return 'Authorization', 'Bearer {}'.format(token)
|