Skip to content

smuggaz/okta-acmehealth-client-django

Repository files navigation

AcmeHealth Samples using Django

The following examples show best practices for using Okta's Sign-In Widget and AuthJS SDK with Django

Overview

AcmeHealth is a starter project for developers looking to incorporate OAuth2/OpenID Connect into their web applications. Using industry best practices, the AcmeHealth project will provide you with an end-to-end example of common authentication scenarios.

Flow

Scenario Summary
Authentication Using the Authorization Code Grant, the Sign-In Widget and AuthJS SDK, request an authorization code from Okta or the Social IDP
Code Extraction Parsed from the /callback URL query parameter, the code is exchanged for an id_token and access_token from Okta
Validate Token If an id_token is requested, it is validated per OpenID Spec 3.1.3.7. If id_token is valid, a local user is created / matched
Set Session Sets a session cookie upon successful login

Samples Provided

Sample Button
Redirect to IdP (Okta) Okta Login
Simple Login Experience using Sign-In Widget Widget Login
Social IdP (LinkedIn) LinkedIn Login

Running the Samples with your Okta Organization

###Pre-requisites This sample application was tested with an Okta organization. If you do not have an Okta organization, you can easily sign up for a free Developer Okta org.

  1. Verify OpenID Connect is enabled for your Okta organization. Admin -> Applications -> Add Application -> Create New App -> OpenID Connect
  1. In the Create A New Application Integration screen, click the Platform dropdown and select Web
  2. Press Create. When the page appears, enter an Application Name. Press Next.
  3. Add the following to the list of Redirect URIs:
  • http://localhost:8080
  • http://localhost:8080/stateful/callback
  1. Click Finish to redirect back to the General Settings of your application.
  2. Copy the Client ID, as it will be needed for the client configuration.
  3. Select the Edit button and change the Client Authentication to Client Secret. Copy the Client Secret, as it will be needed for the client configuration.
  4. Enable CORS access to your Okta organization
  • In the navigation bar, select Security then API.
  • Select the CORS tab
  • Click the Edit button and add http://localhost:8080
  • Save
  1. Finally, select the People tab and Assign to People in your organization.

Build Instructions

With a local copy of the samples, use the following commands on Mac OS X or Linux:

    $ virtualenv venv
    $ source venv/bin/activate
    $ pip install -r requirements.txt

Run the Samples

Begin by syncing the local database for User authentication.

    $ python manage.py migrate

Start the web server with python manage.py runserver [PORT] in the /acmehealth_django project repository. (Hint) You should see the manage.py file.

    $ python manage.py runserver 8080

Navigate to http://localhost:8080/stateful/login to login using the Okta Sign-In Widget or the Okta AuthJS SDK.

About

AcmeHealth Starter Project for SSO

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published