Syncing Groups and Users from Okta SAML Using 'mi-okta-usersync' Script
In addition to configuring Okta authentication in Metric Insights, you can also sync Okta groups and users by using the mi-okta-usersync
script.
General script logic is as follows:
- Group: Groups are added to Metric Insights and any users in that group can also be added. Groups created in Metric Insights will be named as they are in the Okta server. The mapping is 1:1.
- Users: If a user in a group that is being synced does not yet exist in Metric Insights, the user will be created in MI (if so desired).
-
Default user settings for new users: The type of a user created in MI with mi-okta-usersync script is specified by the
--user-type
parameter; if this parameter is not provided, the created user is a regular user with no default settings. Only informational data for the user's profile (user ID, email address, first name, last name) is set, along with group membership.
As an example, if you're syncing all users from an Okta group called 'SomeOktaGroup', mi-okta-usersync will create a corresponding group called 'SomeOktaGroup' in Metric Insights. Then, for each user in the Okta group, mi-okta-usersync will create a corresponding MI user and make sure the MI user is in the MI group called 'SomeOktaGroup'.
Subsequent syncs can be set via a cron job to sync the group and the users in that group as well as adding (if so desired) any new users in that same Office 365 group.
Table of contents:
Provisioning Groups and Users
Note: Run the mi-okta-usersync
script inside the web container.
- For details on parameters available for mi-okta-usersync script, see the Parameters section
- See the Example section for a detailed example on syncing an Okta group in MI
The 'mi-okta-usersync' script is governed by one basic provision
command. Provisioning is the action of creating and syncing Okta groups and users in Metric Insights. Here's an example of a very basic provisioning command using the mi-okta-usersync
script:
$ /opt/mi/bin/ mi-okta-usersync provision \
--okta-host <Okta host> \
--okta-token <Okta token> \
--auto-create all \
--full-summary \
-v \
<Group name>
Note that in order to provision a group we need a few bits of information, namely the Okta host URL, Okta API token, and the group's name.
Note: Okta API tokens have a limited lifetime of 1 month and have to be re-created after expiration.
- See Obtain Okta API token for details on creating a new token
mi-okta-usersync provision Parameters (-h)
In this example we will sync an Okta group containing 2 users with MI.
1. Obtain Okta API Token
Access your Okta host > Security > API > Tokens tab
- To create a new Token, click [Create Token]
- Enter a name for the token, click [Create Token]
- Save the obtained token value. You will need it for syncing Okta user groups with MI
Note: Okta API tokens have a limited lifetime of 1 month and have to be re-created after expiration.
2. Run 'mi-okta-usersync' Script from the Web Container
- Access the
web
container:- MI Simple Installation:
mi-console
- Docker Swarm:
docker exec -it <container name> bash
- Kubernetes:
kubectl exec -n <namespace> -it <pod> -- bash
- OpenShift:
- Single-container pod:
oc exec -it <pod> bash
- Multi-container pod:
oc exec -it <pod> -с <container> bash
- Single-container pod:
- MI Simple Installation:
- Execute
mi-okta-usersync provision
command, syncing all the users from themy_new_group
group - The summary of added groups and users is displayed