Skip to content

Minimal login scenario with Keycloak (OIDC Provider) and Python (Flask)

License

Notifications You must be signed in to change notification settings

Sh3b0/keycloak-sso

Repository files navigation

keycloak-sso

Minimal login scenario with Keycloak (OIDC Provider) and Python (Flask).

Overview

The sequence diagram illustrates the typical interactions between system components to implement a simple login scenario.

Screenshots

  • Application webpage before logging in. Configured locally with self-signed certs for HTTPS.

    login

  • Clicking "Log In" redirects to Keyclock login form.

    • Need to pre-configure connection to the client and sample users/roles in "myrealm".

    keycloak

  • Successful login and redirection.

    success

  • The client session can be inspected at the server

    session

Local Testing

  1. Clone repository

    git clone https://github.com/sh3b0/keycloak-sso
    cd keycloak-sso
  2. Configure certificates in certs directory. Refer to REPORT.md for more details

    • Expected content: tls.crt, tls.key, and ca.crt (issuer CA).
  3. Create .env with environment variables. Sample config:

    CA_PATH=/app/certs/ca.crt
    KEYCLOAK_SERVER_URL=https://keycloak.internal.test
    KEYCLOAK_REALM=myrealm
    KEYCLOAK_CLIENT_ID=demo
    KEYCLOAK_CLIENT_SECRET=<KEYCLOAK_CLIENT_SECRET>
    KEYCLOAK_REDIRECT_URI=https://app.internal.test:5000/callback
  4. Configure domain names for app and keycloak accordingly.

  5. Run keycloak and app containers in the same network.

    docker compose up -d
  6. Login to Keycloak UI with admin:admin, then change credentials.

  7. Create a realm, a client, and sample users for testing.

  8. Access the test client at port 5000.

References

About

Minimal login scenario with Keycloak (OIDC Provider) and Python (Flask)

Topics

Resources

License

Stars

Watchers

Forks