Skip to content

Commit 70c7427

Browse files
awolfdenAdam Wolfman
andauthored
Update UI/UX for Django SSO app (#75)
* Add log streams to audit logs app * Update login page * Update post login page and readme --------- Co-authored-by: Adam Wolfman <[email protected]>
1 parent ab9852c commit 70c7427

File tree

8 files changed

+391
-221
lines changed

8 files changed

+391
-221
lines changed

python-django-sso-example/README.md

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# python-django-sso-example
2+
23
An example Django application demonstrating how to use the [WorkOS Python SDK](https://github.com/workos/workos-python) to authenticate users via SSO.
34

45
## Prerequisites
5-
- Python 3.6+
66

7+
- Python 3.6+
78

89
## Django Project Setup
910

1011
1. Clone the main git repo for these Python example apps using your preferred secure method (HTTPS or SSH).
12+
1113
```bash
1214
# HTTPS
1315
$ git clone https://github.com/workos/python-django-example-applications.git
@@ -21,35 +23,40 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
2123
```
2224

2325
2. Navigate to the Admin Portal example app within the cloned repo.
26+
2427
```bash
2528
$ cd python-django-example-applications/python-django-sso-example
26-
````
27-
29+
```
2830

2931
3. Create and source a Python virtual environment. You should then see `(env)` at the beginning of your command-line prompt.
32+
3033
```bash
3134
$ python3 -m venv env
3235
$ source env/bin/activate
3336
(env) $
3437
```
3538

3639
4. Install the cloned app's dependencies. If the `pip` command doesn't work, try `pip3` instead.
40+
3741
```bash
3842
(env) $ pip install -r requirements.txt
3943
```
4044

4145
5. Obtain and make note of the following values. In the next step, these will be set as environment variables.
46+
4247
- Your [WorkOS API key](https://dashboard.workos.com/api-keys)
4348
- Your [SSO-specific, WorkOS Client ID](https://dashboard.workos.com/sso/configuration)
4449
- The redirect URI. For this example, we'll use http://localhost:8000/auth/callback
4550

4651
6. Ensure you're in the root directory for the example app, `python-django-sso-example/`. Create a `.env` file to securely store the environment variables. Open this file with the Nano text editor. (This file is listed in this repo's `.gitignore` file, so your sensitive information will not be checked into version control.)
52+
4753
```bash
4854
(env) $ touch .env
4955
(env) $ nano .env
5056
```
5157

5258
7. Once the Nano text editor opens, you can directly edit the `.env` file by listing the environment variables:
59+
5360
```bash
5461
export WORKOS_API_KEY=<value found in step 6>
5562
export WORKOS_CLIENT_ID=<value found in step 6>
@@ -59,23 +66,27 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
5966
To exit the Nano text editor, type `CTRL + x`. When prompted to "Save modified buffer", type `Y`, then press the `Enter` or `Return` key.
6067

6168
8. Source the environment variables so they are accessible to the operating system.
69+
6270
```bash
6371
(env) $ source .env
6472
```
6573

6674
You can ensure the environment variables were set correctly by running the following commands. The output should match the corresponding values.
75+
6776
```bash
6877
(env) $ echo $WORKOS_API_KEY
6978
(env) $ echo $WORKOS_CLIENT_ID
7079
(env) $ echo $REDIRECT_URI
7180
```
7281

7382
9. Run the Django migrations. Again, ensure you're in the `python-django-sso-example/` directory where the `manange.py` file is.
83+
7484
```bash
7585
(env) $ python3 manage.py migrate
7686
```
7787

7888
You should see output like:
89+
7990
```bash
8091
Operations to perform:
8192
Apply all migrations: admin, auth, contenttypes, sessions
@@ -85,30 +96,30 @@ An example Django application demonstrating how to use the [WorkOS Python SDK](h
8596
. . .
8697
```
8798

88-
10. In `python-django-sso-example/sso/views.py` change the `CONNECTION_ID` string value to the connection ID that you are targeting. This can be found in the WorkOS Dashboard under the Connection Settings.
99+
10. In `python-django-sso-example/sso/views.py` change the `ORGANIZATION_ID` string value to the organization ID that you are targeting. This can be found in the WorkOS Dashboard under the Organization Settings.
89100

90101
11. The final setup step is to start the server.
91-
```bash
92-
(env) $ python3 manage.py runserver --insecure
93-
```
94102

95-
You'll know the server is running when you see no warnings or errors in the CLI, and output similar to the following is displayed:
103+
```bash
104+
(env) $ python3 manage.py runserver --insecure
105+
```
96106

97-
```bash
98-
Watching for file changes with StatReloader
99-
Performing system checks...
100-
101-
System check identified no issues (0 silenced).
102-
March 18, 2021 - 04:54:50
103-
Django version 3.1.7, using settings 'workos_django.settings'
104-
Starting development server at http://127.0.0.1:8000/
105-
Quit the server with CONTROL-C.
106-
```
107+
You'll know the server is running when you see no warnings or errors in the CLI, and output similar to the following is displayed:
108+
109+
```bash
110+
Watching for file changes with StatReloader
111+
Performing system checks...
107112

108-
Navigate to `localhost:8000` in your web browser. You should see a "Login" link. If you click this link, you'll be redirected to an HTTP `404` page because we haven't set up SSO yet!
113+
System check identified no issues (0 silenced).
114+
March 18, 2021 - 04:54:50
115+
Django version 3.1.7, using settings 'workos_django.settings'
116+
Starting development server at http://127.0.0.1:8000/
117+
Quit the server with CONTROL-C.
118+
```
109119

110-
You can stop the local Django server for now by entering `CTRL + c` on the command line.
120+
Navigate to `localhost:8000` in your web browser. You should see a "Login" link. If you click this link, you'll be redirected to an HTTP `404` page because we haven't set up SSO yet!
111121

122+
You can stop the local Django server for now by entering `CTRL + c` on the command line.
112123

113124
## SSO Setup with WorkOS
114125

@@ -122,15 +133,15 @@ If you get stuck, please reach out to us at [email protected] so we can help.
122133

123134
12. Naviagte to the `python-django-sso-example` directory, which contains the `manage.py` file. Source the virtual environment we created earlier, if it isn't still activated from the steps above. Start the Django server locally.
124135

125-
```bash
126-
$ cd ~/Desktop/python-django-sso-example/
127-
$ source env/bin/activate
128-
(env) $ python3 manage.py runserver
129-
```
136+
```bash
137+
$ cd ~/Desktop/python-django-sso-example/
138+
$ source env/bin/activate
139+
(env) $ python3 manage.py runserver
140+
```
130141

131-
Once running, navigate to http://localhost:8000 to test out the SSO workflow.
142+
Once running, navigate to http://localhost:8000 to test out the SSO workflow.
132143

133-
Hooray!
144+
Hooray!
134145

135146
## Need help?
136147

0 commit comments

Comments
 (0)