Commit 1540d3c8 by Clinton Blackburn Committed by Clinton Blackburn

Using standard JWT issuer for calls to Credentials Service

The client-specific JWT doesn't really make any sense and only causes issues due to needing to configure both. This change updates LMS to use the standard issuer.

LEARNER-3441
parent e8cb8bba
......@@ -27,32 +27,21 @@ ROUTING_KEY = getattr(settings, 'CREDENTIALS_GENERATION_ROUTING_KEY', None)
MAX_RETRIES = 11
def get_api_client(api_config, student):
def get_api_client(api_config, user):
"""
Create and configure an API client for authenticated HTTP requests.
Args:
api_config: CredentialsApiConfig object
student: User object as whom to authenticate to the API
user: User object as whom to authenticate to the API
Returns:
EdxRestApiClient
"""
# TODO: Use the system's JWT_AUDIENCE and JWT_SECRET_KEY instead of client ID and name.
client_name = api_config.OAUTH2_CLIENT_NAME
try:
client = Client.objects.get(name=client_name)
except Client.DoesNotExist:
raise ImproperlyConfigured(
'OAuth2 Client with name [{}] does not exist.'.format(client_name)
)
scopes = ['email', 'profile']
expires_in = settings.OAUTH_ID_TOKEN_EXPIRATION
jwt = JwtBuilder(student, secret=client.client_secret).build_token(scopes, expires_in, aud=client.client_id)
jwt = JwtBuilder(user).build_token(scopes, expires_in)
return EdxRestApiClient(api_config.internal_api_url, jwt=jwt)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment