I used Expression Language to handle various cases.

Introduction

This time, we will introduce the flexibility of Expression Language, which is a function of Okta, and specific usage scenes through use cases.

What is Expression Language

ユーザーの属性情報をユーザープロファイルに保存する前や、認証、プロビジョニングでSaaSにユーザー同期する前に、属性情報を参照、変換、組み合わせることができる機能です。
例えば、Expression Languageを用いて記載することによってuser@test.localのドメイン部を削除してOkta上にユーザー名を作成することができます。他にも、first Nameとlast Nameを組み合わせて表示させることも可能です。簡単にまとめると、属性情報をカスタマイズできる関数ということです。

Example of how to write Expression Language

・Remove @ from the email address for users on Okta
String.substringBefore(appuser.userName, "@")

・ Match the first name and last name of the user name on Okta
appuser.firstname + appuser.lastname

There are many ways of writing such as

In addition, you can check the Expression Language from the following page.
https://help.okta.com/en/prod/Content/Topics/Settings/settings-customization-variables.htm

real use case

Here are some specific use cases for Expression Language.

[Use case 1]

Issue: When synchronizing users from AD to Okta, I want to display only the user name on Okta

Solution: Use Expression Language that removes the part after @ and displays only the user name

Expression Language: String.substringBefore(appuser.userName, "@")

【Setting method】

  1. From the Okta admin screen, go to Directory Integrations
  2. Move to the Provisioning tab and click the Edit button of General of To Okta
  3. Change Okta Username format to Custom
  4. Enter the Expression Language as shown below (The figure below reflects setting methods 1 to 4)

* If you set it, it will be automatically displayed with only the user name after importing the user.

[Use case 2]

Issue: I want to unify the domain part of the email address when merging companies

Solution: Delete the domain part below @ and add the domain part "@test.local" to the Expression Language

Expression Language: String.substringBefore(appuser.userName, "@") + "@test.local"

This time, we will use the following users.

【Setting method】

  1. From the Okta admin screen, go to Directory Integrations
  2. Move to the Provisioning tab and click the Edit button of General of To Okta
  3. Change Okta Username format to Custom
  4. Enter the Expression Language as shown below (The figure below reflects setting methods 1 to 4)

* The domain part of the user name has been changed to "@test.local".

[Use case 3]

Issue: There are email format users and users without @ on Okta, so I want to unify them

解決策:「test@test.local」と「test2」のユーザーがいるので、下記2点を満たすExpression Languageを設定
・test@test.localのユーザーはそのまま
・test2のユーザーに対して、@test.localをユーザー名に追加

Expression Language:
String.stringContains(user.login,"@")?String.substringBefore(user.login,"@")+"@test.local" : user.login + "@test.local"

*Expression LanguageではIF文を記載することができます。
上記のExpression Languageは、「ユーザー名に@が入っているユーザーに関しては@以下を@test.localに変更」「ユーザー名に@が入っていないユーザーに関しては、ユーザー名に@test.localを追加」という構文を記載しています。

Expression Languageを用いて、下図のような@以下がなく、「Expression-demo」となっているユーザーにドメインを追加します。

【Setting method】

  • From the Okta admin screen, go to Applications > Applications
  • Go to the Sign On tab and click the Edit button in Settings
  • Change Application Username format in Credentials Details to Custom
  • Enter Expression Language as shown below (The figure below reflects setting methods 1 to 4)

[Use case 4]

Challenge: I want to create a group rule that assigns users whose Department is "Marketing" and ManagerId is "1" (creating a complex group rule)

Solution: Combine attributes to create a rule that adds users to groups where department=Marketing and ManagerId=1

Expression Language: user.department=="Marketing" AND user.managerId=="1"

【Setting method】

1: Go to Directory>People and search for a user

2: Specify Department and ManagerId in the Profile item

3: Go to Directories->Groups->Rules

4: Select Add Rule

5: Click Use Okta Expression Language (advanced) in the IF item

6: Describe Expression Language in the item

7: Set the Name and Assign to items and click Save (The figure below shows the state of setting methods 3 to 7)

* Users are actually assigned by group rules.

Summary

This time, we introduced the functions of Expression Language with use cases, but it can be used in many other situations.
By using Expression Language, even in a complex environment, it is possible to respond flexibly to many environments.

また、Oktaは多くの柔軟な機能を持っておりますので、IDaaSの検討をされている方は是非弊社までご連絡いただければと思います。

Inquiry/Document request

In charge of Macnica Okta Co., Ltd.

Mon-Fri 8:45-17:30