Skip to content

Commit

Permalink
Add compliance_fix for create_azure_backend
Browse files Browse the repository at this point in the history
Related to #65
  • Loading branch information
lepture committed Oct 31, 2020
1 parent 1ab459f commit 1851011
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions loginpass/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"""


def create_azure_backend(name, tenant, version=2):
def create_azure_backend(name, tenant, version=2, compliance_fix=None):

base_url = 'https://login.microsoftonline.com/common/'
base_url = 'https://login.microsoftonline.com/' + tenant
if version == 1:
metadata_url = base_url + '.well-known/openid-configuration'
metadata_url = base_url + '/.well-known/openid-configuration'
elif version == 2:
metadata_url = base_url + 'v2.0/.well-known/openid-configuration'
metadata_url = base_url + '/v2.0/.well-known/openid-configuration'
else:
raise ValueError('Invalid version value')

Expand All @@ -29,13 +29,11 @@ class AzureAD(object):

def load_server_metadata(self):
metadata = super(AzureAD, self).load_server_metadata()
# fix issuer value
issuer = metadata['issuer']
issuer = issuer.replace('{tenantid}', tenant)
metadata['issuer'] = issuer
if compliance_fix:
metadata = compliance_fix(metadata)
return metadata

return AzureAD


Azure = create_azure_backend('azure', 'common')
Azure = create_azure_backend('azure', 'consumers')

0 comments on commit 1851011

Please sign in to comment.