https://github.com/stackexchange/so4t_scim_user_deactivation
https://github.com/stackexchange/so4t_scim_user_deactivation
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/stackexchange/so4t_scim_user_deactivation
- Owner: StackExchange
- License: mit
- Created: 2024-06-07T13:50:59.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-11-12T18:17:55.000Z (8 months ago)
- Last Synced: 2026-03-08T19:55:55.860Z (5 months ago)
- Language: Python
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Stack Internal SCIM-based User Deactivation
A SCIM API script for Stack Internal that can automate the Deactivation of a list of specific existing users.
## Requirements
* A Stack Internal instance with SCIM enabled (Basic, Business, or Enterprise)
* Python 3.8 or higher ([download](https://www.python.org/downloads/))
* Operating system: Linux, MacOS, or Windows
## Setup
[Download](https://github.com/StackExchange/so4t_scim_user_deactivation/archive/refs/heads/main.zip) and unpack the contents of this repository
**Installing Dependencies**
* Open a terminal window (or, for Windows, a command prompt)
* Navigate to the directory where you unpacked the files
* Install the dependencies: `pip3 install -r requirements.txt`
**Enabling and Authenticating SCIM**
To use the SCIM API, you'll first need to enable SCIM in the admin settings. Second, you'll need to generate a SCIM token to authenticate the API calls.
- [SCIM Documentation for Basic and Business](https://stackoverflowteams.help/en/articles/4538506-automated-user-provisioning-scim-overview)
- [SCIM Documentation for Enterprise](https://support.stackenterprise.co/support/solutions/articles/22000236123-system-for-cross-domain-identity-management-scim-2-0-support)
> NOTE: The SCIM token differs from the API token used for Stack Internal API.
## Usage
Create a file named `users.csv` in the same directory as the script.
You can find a CSV template [here](https://github.com/StackExchange/so4t_scim_user_deactivation/blob/main/Templates/users.csv).
- The CSV should have a single column with no header row
- Each row can be an email address or external ID
The script will read the CSV and Activate each user found in the list. If the user is not found, the script will skip to the next user and print a message to the console.
In a terminal window, navigate to the directory where you unpacked the script. Run the script with the `--csv` flag, replacing the URL, token, and path to CSV file with your own:
* For Basic and Business: `python3 so4t_scim_user_deactivation.py --url "https://stackoverflowteams.com/c/TEAM-NAME" --token "YOUR_SCIM_TOKEN" --csv users.csv`
* For Enterprise: `python3 so4t_scim_user_deactivation.py --url "https://SUBDOMAIN.stackenterprise.co" --token "YOUR_SCIM_TOKEN" --csv users.csv`
> If API requests to the Stack Internal server must be made through a proxy, you can use the `--proxy` flag to specify the proxy URL. Example: `python3 so4t_scim_user_deactivation.py --url "https://SUBDOMAIN.stackenterprise.co" --token "YOUR_SCIM_TOKEN" --proxy "PROXY.EXAMPLE.COM:PORTNUMBER"`
## Support, security, and legal
If you encounter problems using the script, please leave feedback in the Github Issues. You can also clone and change the script to suit your needs. It is provided as-is, with no warranty or guarantee of any kind.