Merge pull request #2585 from coreos-inc/oidc-auth-header

Add Authorization header with token to user info call
This commit is contained in:
josephschorr 2017-04-27 11:28:25 -04:00 committed by GitHub
commit 3e287978e1
2 changed files with 9 additions and 2 deletions

View file

@ -101,7 +101,11 @@ class OAuthService(object):
'alt': 'json',
}
got_user = http_client.get(self.user_endpoint(), params=token_param)
headers = {
'Authorization': 'Bearer %s' % token,
}
got_user = http_client.get(self.user_endpoint(), params=token_param, headers=headers)
if got_user.status_code // 100 != 2:
raise OAuthGetUserInfoException('Non-2XX response code for user_info call: %s' %
got_user.status_code)

View file

@ -153,7 +153,10 @@ def preferred_username(request):
@pytest.fixture
def userinfo_handler(oidc_service, preferred_username):
@urlmatch(netloc=r'fakeoidc', path=r'/userinfo')
def handler(_, __):
def handler(_, req):
if req.headers.get('Authorization') != 'Bearer sometoken':
return {'status_code': 401, 'content': 'Missing expected header'}
content = {
'sub': 'cooluser',
'preferred_username':preferred_username,