mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
Added authorization headers for all requests
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
from client.authentication import create_jwt_token
|
||||
|
||||
from app.dao.tokens_dao import get_unsigned_token
|
||||
|
||||
|
||||
def create_authorization_header(service_id, path, method, request_body=None):
|
||||
if request_body:
|
||||
token = create_jwt_token(
|
||||
request_method=method,
|
||||
request_path=path,
|
||||
secret=get_unsigned_token(service_id),
|
||||
client_id=service_id,
|
||||
request_body=request_body)
|
||||
|
||||
else:
|
||||
token = create_jwt_token(request_method=method,
|
||||
request_path=path,
|
||||
secret=get_unsigned_token(service_id),
|
||||
client_id=service_id)
|
||||
|
||||
return 'Authorization', 'Bearer {}'.format(token)
|
||||
|
||||
Reference in New Issue
Block a user