forked from Mirror/python-keycloak
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1007 B
35 lines
1007 B
"""
|
|
|
|
"""
|
|
|
|
import json
|
|
|
|
from keycloak.exceptions import raise_error_from_response, KeycloakGetError
|
|
from .connection import ConnectionManager
|
|
from .urls_patterns import URL_WELL_KNOWN
|
|
|
|
|
|
class Keycloak:
|
|
|
|
def __init__(self, server_url, client_id, realm_name, client_secret_key=None):
|
|
self.__client_id = client_id
|
|
self.__client_secret_key = client_secret_key
|
|
self.__realm_name = realm_name
|
|
|
|
self.__connection = ConnectionManager(base_url=server_url,
|
|
headers={},
|
|
timeout=60)
|
|
|
|
def get_well_know(self):
|
|
params = {"realm-name": self.__realm_name}
|
|
data_raw = self.__connection.raw_get(URL_WELL_KNOWN.format(**params))
|
|
raise_error_from_response(data_raw, KeycloakGetError)
|
|
return json.loads(data_raw.text)
|
|
|
|
def auth(self):
|
|
"""
|
|
|
|
http://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
|
|
|
|
:return:
|
|
"""
|