adding sample settings file
diff --git a/clients/python/README.md b/clients/python/README.md
index 907817d..dd70088 100644
--- a/clients/python/README.md
+++ b/clients/python/README.md
@@ -1,10 +1,53 @@
# Airavata Custos Python SDK
+Folder structure
+
+- airavata_custos : client
+ - admin
+ - security
+
+- custos: thrift generated service APIs and models
+- tests: test cases
+
Create a virtual environment
-- python3 -m venv venv
+
+ python3 -m venv venv
Activate the virtual environment
-- source venv/bin/activate
+
+ source venv/bin/activate
Install dependencies
-- pip install -r requirements_dev.txt
\ No newline at end of file
+
+ pip install -r requirements_dev.txt
+
+Server configuration should be kept in a INI file in the following format. For more information refer to sample_settings.ini file
+
+ [IAMSeverSettings]
+ KEYCLOAK_AUTHORIZE_URL =
+ KEYCLOAK_TOKEN_URL =
+ KEYCLOAK_USERINFO_URL =
+ KEYCLOAK_LOGOUT_URL =
+ VERIFY_SSL =
+
+ [ProfileServerSettings]
+ PROFILE_SERVICE_HOST =
+ PROFILE_SERVICE_PORT =
+
+Keycloak connections
+
+ - authenticate_user
+ - authenticate_account
+ - authenticate_using_refresh_token
+
+Admin operations
+
+ - is_username_available
+ - register_user
+ - is_user_enabled
+ - enable_user
+ - delete_user
+ - is_user_exist
+ - get_user
+ - get_users
+ - reset_user_password
\ No newline at end of file
diff --git a/clients/python/airavata_custos/sample_settings.ini b/clients/python/airavata_custos/sample_settings.ini
index c9a1e1c..18eb04b 100644
--- a/clients/python/airavata_custos/sample_settings.ini
+++ b/clients/python/airavata_custos/sample_settings.ini
@@ -6,5 +6,5 @@
VERIFY_SSL = no
[ProfileServerSettings]
-PROFILE_SERVICE_HOST = '0.0.0.0'
-PROFILE_SERVICE_PORT = '8081'
\ No newline at end of file
+PROFILE_SERVICE_HOST = 0.0.0.0
+PROFILE_SERVICE_PORT = 8081
\ No newline at end of file
diff --git a/clients/python/airavata_custos/security/keycloak_connectors.py b/clients/python/airavata_custos/security/keycloak_connectors.py
index 05816c2..07e8dd8 100644
--- a/clients/python/airavata_custos/security/keycloak_connectors.py
+++ b/clients/python/airavata_custos/security/keycloak_connectors.py
@@ -50,11 +50,11 @@
"""
:param account_credentials: object of AccountCredentials class
- :return: Token object, UserInfo object
+ :return: Token object, Account info object
"""
try:
- token, user_info = self._get_token_and_user_info_redirect_flow(account_credentials)
- return token, user_info
+ token, account_info = self._get_token_and_user_info_redirect_flow(account_credentials)
+ return token, account_info
except Exception as e:
return None
@@ -71,6 +71,29 @@
except Exception as e:
return None
+ def get_authorization_token(self, client_credentials, tenant_id, username=None):
+ """
+ This method created a authorization token for the user or a service account
+ In case of a service account username will be null
+ :param client_credentials: object of class client_credentials
+ :param tenant_id: gateway id of the client
+ :param username: username of the user for which authorization token is being created
+ :return: AuthzToken
+ """
+ client = BackendApplicationClient(client_id=client_credentials.client_id)
+ oauth = OAuth2Session(client=client)
+ token = oauth.fetch_token(
+ token_url=self.keycloak_settings.token_url,
+ client_id=client_credentials.client_id,
+ client_secret=client_credentials.client_secret,
+ verify=client_credentials.verify_ssl)
+
+ access_token = token.get('access_token')
+ return AuthzToken(
+ accessToken=access_token,
+ claimsMap={'gatewayID': tenant_id, 'userName': username})
+
+
def _get_token_and_user_info_password_flow(self, client_credentials):
oauth2_session = OAuth2Session(client=LegacyApplicationClient(client_id=client_credentials.client_id))
@@ -105,28 +128,6 @@
verify=self.keycloak_settings.VERIFY_SSL)
return self._process_token(token)
- def get_authorization_token(self, client_credentials, tenant_id, username=None):
- """
- This method created a authorization token for the user or a service account
- In case of a service account username will be null
- :param client_credentials: object of class client_credentials
- :param tenant_id: gateway id of the client
- :param username: username of the user for which authorization token is being created
- :return: AuthzToken
- """
- client = BackendApplicationClient(client_id=client_credentials.client_id)
- oauth = OAuth2Session(client=client)
- token = oauth.fetch_token(
- token_url=self.keycloak_settings.token_url,
- client_id=client_credentials.client_id,
- client_secret=client_credentials.client_secret,
- verify=client_credentials.verify_ssl)
-
- access_token = token.get('access_token')
- return AuthzToken(
- accessToken=access_token,
- claimsMap={'gatewayID': tenant_id, 'userName': username})
-
@classmethod
def _process_token(cls, token):