tree: e630248bbcf17666dd53c374e18aebe60f811dc6 [path history] [tgz]
  1. build/
  2. custos/
  3. custos_python_sdk.egg-info/
  4. custos_sdk.egg-info/
  5. .gitignore
  6. __init__.py
  7. LICENSE
  8. README.md
  9. requirements.txt
  10. setup.cfg
  11. setup.py
custos-client-sdks/custos-python-sdk/README.md

Apache Custos Python SDK

The Apache Custos Python SDK for third party clients to integrate with Custos middleware

Folder Structure

  • custos

    Includes gRPC stubs generated by a protoc compiler. Mainly contains data model and functions. You may need to import data model packages to integrate with clients.

  • clients

    Includes integration clients, which you want to import and integrate with your code to access Custos middleware.

  • samples

    Includes set of sample implementation of integration clients to demo the integration with Custos middleware

  • transport

    Includes connection handling classes

Before Integration

  • Create a virtual environment

    python3 -m venv venv
    
  • Activate the virtual environment

    source venv/bin/activate
    
  • Install dependencies

    pip install -r requirements.txt
    
  • Create a INI file containing server configuration details. For more information refer to default settings file

    settings.ini

Generating Distribution Archives (Optional)

You can generate *.tar.gz or .whl distribution and install to any external project.

  • Create a virtual environment

    python3 -m venv venv
    
  • Activate the virtual environment

    source venv/bin/activate
    
  • Make sure you have the latest versions of setuptools and wheel installed

    pip install  wheel
    
  • Now run this command from the same directory where setup.py is located

    python3 setup.py sdist bdist_wheel
    
  • This command should output a lot of text and once completed should generate two files in the dist directory

    dist/
        custos_python_sdk-1.0.0-py3-none-any.whl
        custos-python-sdk-1.0.0.tar.gz
    

You should be able to install those packages into your project.

Integrate With Your Clients

There are three types of tokens used for access custos APIs.

  • Client Token (Base64 encoded Custos_Client_Id +“:”+ Custos_Client_Sec)

  • Admin Token (Access Token of Admin User)

  • User Token (Access Token of Generic User)

  • tenant_management_client

    • create_admin_tenant (client_name, requester_email, admin_frist_name, admin_last_name, admin_email, admin_username, admin_password, contacts, redirect_uris, client_uri, scope, domain, logo_uri, comment)
    • create_tenant (client_token, client_name, requester_email, admin_frist_name, admin_last_name, admin_email, admin_username, admin_password, contacts, redirect_uris, client_uri, scope, domain, logo_uri, comment)
    • get_credentials (client_token)
    • get_tenant (client_token, client_id)
    • update_tenant (client_token, client_id, client_name, requester_email, admin_frist_name, admin_last_name, admin_email, admin_username, admin_password, contacts, redirect_uris, client_uri, scope, domain, logo_uri, comment)
    • delete_tenant (client_token, client_id)
    • add_tenant_roles (client_token, roles, is_client_level)
    • add_protocol_mapper (client_token, roles, is_client_level)
    • get_child_tenants ( client_token, offset, limit, status)
    • get_all_tenants ( client_token, email)

Sample implementations can be found at tenant_management_samples

  • identity_management_client

    • authenticate(client_token, username, password)
    • is_authenticated( client_token, user_access_token, username)
    • get_service_account_access_token( client_token)
    • authorize( client_id, redirect_uri, response_type, scope, state)
    • token( client_token, redirect_uri, code)
    • get_credentials( client_token, client_id)
    • get_oidc_configuration( client_token, client_id)

Sample implementations can be found at identity_management_sample

  • user_management_client

    • register_user(client_token, username, first_name, last_name, password, email, is_temp_password)
    • register_and_enable_users( admin_token, users)
    • add_user_attributes( user_token, attributes, users)
    • delete_user_attributes( user_token, attributes, users)
    • enable_user( client_token, username)
    • add_roles_to_users( admin_token, usernames, roles, is_client_level)
    • is_user_enabled( client_token, username)
    • is_username_available( client_token, username)
    • get_user( client_token, username)
    • find_users( client_token, offset, limit, username=None, firstname=None, lastname=None, email=None)
    • reset_password( client_token, username, password)
    • delete_user( admin_token, username)
    • delete_user_roles( admin_token, username, client_roles, realm_roles)
    • update_user_profile( user_token, username, email, first_name, last_name)

Sample implementations can be found at user_management_samples