NOTE: This is not meant to be a fully-fledged, IDP-agnostic SCIM server. This server was designed specifically to integrate with Okta.
Please read How to Build a Flask SCIM Server Configured for Use with Okta to see how this app was created.
To use Okta, you'll need to change a few things. First, you'll need to create a free developer account at https://developer.okta.com/signup/. After doing so, you'll get your own Okta domain, that has a name like https://dev-123456.okta.com
.
- Clone the repo, open terminal and
cd
into the project root. - Create a new virtualenv in the root folder with
virtualenv env
- Run the virtual environment with
source env/bin/activate
- Install necessary Python packages with
pip install -r requirements.txt
- Create a new Postgres database
scim
atpostgresql://localhost/scim
. Enter the psql shell by opening a new terminal tab and typingpsql postgres
. Create the DB withCREATE DATABASE scim;
(Run\l
to double check the database has been created) - Go back to the terminal tab that is in the flask app root. Run the following commands to create migrations and tables in the
scim
database:python manage.py db init
python manage.py db migrate
python manage.py db upgrade
Feel free to hop back to your postgres tab and run
\c scim
to navigate into the scim db, then\dt
to see your new tables:groups
,users
,link
. (Link is a table facilitating the many-to-many relationship between users and groups)
- Everything should be setup now to run the server locally. Finally run
python app.py
to do so. You should now have your SCIM server running on http://localhost:5000.
- Once you have ngrok installed, run
./ngrok http 5000
to create a tunnel from ngrok to your http://localhost:5000. Copy thehttps
Forwarding URL created by ngrok as you will need it later.
- Now it's time to create a new SCIM integration in Okta. If your SCIM app(s) are already setup on the Okta side, feel free to skip ahead to Test the SCIM Server. There are two options that will work with this server, and I will ALWAYS recommend the first, which is using an Okta SCIM template application.
- In your Okta dashboard, go to Applications -> Applications, then click the Browse App Catalogue button. Search for SCIM 2.0 Test App (Header Auth) and click the Add button once you have it pulled up.
- In the General Settings tab, click Next.
- We will set this up as a SWA application, so in the Sign-On Options tab, click Secure Web Authentication.
- Click Done.
- Tab over to Provisioning and click Configure API Integration.
- Check Enable API integration.
- In the Base URL field, paste in the ngrok url you generated above with /scim/v2 appended to the end. In the API Token field, type Bearer 123456789. (Later on we will go over how to customize this auth header, but out-of-the-box, the SCIM server expects this value)
- Click Test API Credentials and you should get a success message like the below:
You can navigate to
http://localhost:4040
to see the request from Okta on this request, as well as the response from the SCIM server.
- Click Save.
Now your Provisoning tab will look a bit different.
- Click Edit next to Provisioning to App and check off:
- Create Users
- Update User Attributes
- Deactivate Users
And Save.
Feel free to skip over this section to Test the SCIM Server if you set your SCIM integration up above.
- In your Okta dashboard, go to Applications -> Applications, then click the Create App Integration button. For this setup we will select SWA - Secure Web Authentication. Click Next.
- You can put whatever you'd like for the App Name and App Login Page URL, as we will just be loking at the SCIM functionality and not the SWA aspect of this app. Click Finish.
- In the General tab of the app, click Edit and toggle Provisioning from None to SCIM. Click Save.
- Your app should now have a Provisioning tab. Tab over to it and fill out the integration settings like the below image. Make the Authorization header 123456789. You can change this later in the SCIM flask app.
- Click Test Connector Configuration and you should see the following success confirmation:
- At which point, you can now click Save.
You can navigate to
http://localhost:4040
to see the request from Okta on this request, as well as the response from the SCIM server.
- Now your Provisoning tab will look a bit different. Click Edit next to Provisioning to App and check off:
- Create Users
- Update User Attributes
- Deactivate Users
And Save.
You should now be set on the Okta side to start testing the SCIM server.
This example uses the following open source libraries:
Please post any questions as comments on the How to Build a Flask SCIM Server Configured for Use with Okta, or visit our Okta Developer Forums.
Apache 2.0, see LICENSE.