def create_authority(tenant, *args, **kwargs): if not tenant: raise Exception("Tenant name is required for Azure Authroity") conf_uri = 'https://login.windows.net/%s/.well-known/openid-configuration' % tenant res = requests.get(conf_uri, headers={'content-type': 'application/json'}) if res.status_code != 200: raise Exception("Failed to get OpenID Configuration") meta = ProviderMeta.from_json(res.content) authority, created = Authority.objects.get_or_create( identifier=meta.issuer, vender=__package__, tenant=tenant, ) if created: authority.short_name = "Azure" authority.save() authority.auth_metadata_object = meta authority.save() authority.update_key() return authority
def create_authority(tenant=None, *args, **kwargs): conf_uri = "https://accounts.google.com/.well-known/openid-configuration" authority, created = Authority.objects.get_or_create(identifier="accounts.google.com", vender=__package__) if tenant: authority.tenant = tenant if created: authority.short_name = "Google" authority.save() res = requests.get(conf_uri, headers={"content-type": "application/json"}) if res.status_code != 200: raise Exception("Failed to get OpenID Configuration") authority.auth_metadata_object = ProviderMeta.from_json(res.content) authority.save() authority.update_key() return authority
def create_authority(tenant=None, *args, **kwargs): authority, created = Authority.objects.get_or_create( identifier='https://self-issued.me', # Connect 7.1 vender=__package__, ) if not created: return authority if tenant: authority.tenant = tenant if created: authority.short_name = "SelfIssued" authority.save() meta = ''' { "authorization_endpoint": "openid:", "issuer": "https://self-issued.me", "scopes_supported": ["openid", "profile", "email", "address", "phone"], "response_types_supported": ["id_token"], "subject_types_supported": ["pairwise"], "id_token_signing_alg_values_supported": ["RS256"], "request_object_signing_alg_values_supported": ["none", "RS256"] }''' authority.auth_metadata_object = ProviderMeta.from_json(meta) authority.save() #: Authoriy public key can not be resolved. return authority
def get(self, uri): r = requests.get( uri, headers={"Accept": 'application/json'}) return ProviderMeta.from_json(r.content)