Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SSO] KeyCloak Setup and Implementation #1338

Closed
6 tasks done
snyaggarwal opened this issue Jul 22, 2022 · 19 comments
Closed
6 tasks done

[SSO] KeyCloak Setup and Implementation #1338

snyaggarwal opened this issue Jul 22, 2022 · 19 comments
Assignees
Labels
api2 OCL API v2 documentation-needed enhancement New feature or request web2 OCL WEB v2

Comments

@snyaggarwal
Copy link
Contributor

snyaggarwal commented Jul 22, 2022

Tasks (High Level)

  • Setup Keycloak docker container
  • Configure Keycloak (manual) -- realm,client,roles
  • Use django-keycloak-auth or some generic django+openid-connector package.
  • Integrate OCL API with KeyCloak using above package (or custom) and using openid-connect (not SAML)
  • Plugin authenticate process to get user token
  • Plugin Signup Process.

Questions:

  • Whats the password encryption scheme of KeyCloak? Can the password be migrated from django to KeyCloak?

Other Notes:

  • TermBrowser may need to talk to KeyCloak for initiating signup process via keyCloak
  • Django should always ask keycloak if user’s authenticated or not
@snyaggarwal snyaggarwal added api2 OCL API v2 enhancement New feature or request web2 OCL WEB v2 labels Jul 22, 2022
@snyaggarwal snyaggarwal self-assigned this Jul 22, 2022
@paynejd
Copy link
Member

paynejd commented Jul 26, 2022

Migration to KeyCloak will change the API tokens for all users

@snyaggarwal
Copy link
Contributor Author

snyaggarwal commented Jul 28, 2022

Task Steps:

  • KeyCloak Setup:

    • Docker container (part of ocl-api-core docker-compose.yml)
    • (manual) Create/Configure realm OCL-<env> (this should be different for each env)
    • Create Client (ocl-<env>) in OCL-<env> realm with base URL (ocl-qa with base URL https://api.qa.agrichain.com)
    • Set client's Access Type as confidential and copy client-id/secret from Credentials
    • Add roles in client if any.
    • Create Users in OCL-<env> realm, set credentials
  • Configuring OCLAPI:

    • Update the following env vars:
      • OIDC_SERVER_URL
      • OIDC_SERVER_INTERNAL_URL (should be same as OIDC_SERVER_URL for non-dev)
      • OIDC_REALM
      • OIDC_RP_CLIENT_ID
      • OIDC_RP_CLIENT_SECRET

@snyaggarwal
Copy link
Contributor Author

snyaggarwal commented Aug 1, 2022

TODO:

  • Signup
  • Forgot password
  • Token expiry handling on TermBrowser

@rkorytkowski
Copy link
Contributor

@snyaggarwal I think we need to revisit the approach a bit and when switching to use oidc server we should really be redirecting users to Keycloak for login / logout / singup / forgot password. We can then easily rely on Keyclock providing MFA, adding other identity providers like Google, Facebook, etc. We are also more secure as OCLAPI code is not storing or handling any user credentials and we are not responsible for any password leaks. See https://oauth.net/2/grant-types/password/ which explicitly says it is not recommended that this grant be used at all anymore.

@rkorytkowski
Copy link
Contributor

https://www.keycloak.org/docs/latest/server_development/#_themes is how we would go about customizing the keycloak theme.

@snyaggarwal
Copy link
Contributor Author

@rkorytkowski Alight! I am working on the setup.

@snyaggarwal
Copy link
Contributor Author

snyaggarwal added a commit to OpenConceptLab/oclsso that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclsso that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclsso that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Aug 8, 2022
@paynejd
Copy link
Member

paynejd commented Oct 4, 2022

Key behaviors that need to be tested as deploy on the QA and staging environments:

  • Sign up
  • Sign in
  • Sign out
  • Forgot/Reset password
  • Admin has a few more actions

@paynejd
Copy link
Member

paynejd commented Oct 4, 2022

Next stesps:

  • Merge into master, deploy to QA
  • Test in QA
  • Sunny to write document describing how a client should interact with KeyCloak, using Dictionary Manager as the example

snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 6, 2022
@snyaggarwal
Copy link
Contributor Author

@rkorytkowski Moving this to Code Review.

snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 7, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 10, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 13, 2022
snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 13, 2022
… env vars | using client creds in exchange token call
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 13, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 13, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 17, 2022
snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 17, 2022
snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 17, 2022
@snyaggarwal
Copy link
Contributor Author

@paynejd @rkorytkowski A new Client integration documentation

snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 17, 2022
snyaggarwal added a commit to OpenConceptLab/oclweb2 that referenced this issue Oct 18, 2022
snyaggarwal added a commit to OpenConceptLab/oclapi2 that referenced this issue Oct 18, 2022
@snyaggarwal
Copy link
Contributor Author

@jamlung-ri @paynejd @rkorytkowski This is now merged with master and deployed on QA (with SSO disabled)

@jamlung-ri
Copy link
Contributor

@paynejd and @jamlung-ri to test this on Dev

@rkorytkowski
Copy link
Contributor

rkorytkowski commented Nov 2, 2022

We'll enable it in OCL online with #1405, which awaits #1389.

@paynejd
Copy link
Member

paynejd commented Nov 2, 2022

Note that OID-compatible features for the API were merged into master and were deployed to all environments. KeyCloak is deployed for OCL Online and only a single instance will be used for all environments.

Currently, SSO has been enabled only on dev, and that included a migration of user accounts from dev.

Next steps include:

  • Integrating OpenMRS Dictionary Manager with KeyCloak and testing
  • Migrating user accounts and activating SSO in each environment + testing
  • Identifying dependencies between the OCL Online rollout and upcoming support for the WHO-hosted Azure Active Directory deployment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api2 OCL API v2 documentation-needed enhancement New feature or request web2 OCL WEB v2
Projects
None yet
Development

No branches or pull requests

4 participants