mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 15:22:24 -05:00
30 lines
957 B
Python
30 lines
957 B
Python
from flask import current_app
|
|
from client.authentication import create_jwt_token
|
|
|
|
from app.dao.api_key_dao import get_unsigned_secret
|
|
|
|
|
|
def create_authorization_header(path, method, request_body=None, service_id=None):
|
|
if service_id:
|
|
client_id = service_id
|
|
secret = get_unsigned_secret(service_id)
|
|
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)
|