mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-30 06:21:50 -05:00
Merge branch 'master' into proxy-to-alpha
Conflicts: config.py
This commit is contained in:
@@ -1,21 +1,29 @@
|
||||
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(service_id, path, method, request_body=None):
|
||||
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=get_unsigned_secret(service_id),
|
||||
client_id=service_id,
|
||||
secret=secret,
|
||||
client_id=client_id,
|
||||
request_body=request_body)
|
||||
|
||||
else:
|
||||
token = create_jwt_token(request_method=method,
|
||||
request_path=path,
|
||||
secret=get_unsigned_secret(service_id),
|
||||
client_id=service_id)
|
||||
secret=secret,
|
||||
client_id=client_id)
|
||||
|
||||
return 'Authorization', 'Bearer {}'.format(token)
|
||||
|
||||
Reference in New Issue
Block a user