My Home NW Lab

逸般の誤家庭のネットワーク

SSLOモジュールを用いたBIG-IP Forward Proxy構成でのMicrosoft 365 (MS365)のテナント制限

SSLO (SSL Orchestrator)モジュールを用いて、BIG-IP Forward Proxy構成でMicrosoft 365 (MS365)のテナント制限を設定する方法を整理します。

本記事ではSSLOの v17.0.0.1-10.1 で実装された Office 365 Tenant Restrictions as a service の機能を用います。

techdocs.f5.com

Office 365 Tenant Restrictions as a service
SSL Orchestrator 10.1 now offers Office 365 Tenant Restrictions within the SSL Orchestrator interface, specifically in the F5 tab as part of the Solutions Catalog. This update enables organizations to control their users' access only to the company Office 365 resources while blocking access to personal/non-company Office 365 resources. The SSL Orchestrator inserts Microsoft "Tenant-Restriction" HTTP headers into outbound HTTP flows and provides a mechanism to allow or deny access to O365 resources based on organizational requirements.

AskF5 | Release Notes: F5 SSL Orchestrator Release Notes version 17.0.0.1-10.1

v17.0.0.1-10.1 以前の場合は、SSLOモジュールではなく、iRulesを用いた実装方法があるため下記の記事を参考にしてください。

myhomenwlab.hatenablog.com

検証環境

本記事は下記のバージョンで検証を行っております。

  • F5 BIG-IP Virtual Edition Version 17.0.0.1
    BIG-IPのモジュールは、LTM, APM, SSLOを有効化しております。

  • SSL Orchestrator Package Version 10.1.15 (v17.0.0-10.1.15)
    Package: f5-iappslx-ssl-orchestrator-17.0.0-10.1.15.noarch
    SSLOはiApps LXのパッケージとして提供されているため、個別のバージョン情報があります。

SSLOのGuide Configurationの設定情報は下記をベースにしております。下記の記事はv16系の情報ですが、v17系でも根本的な設定方法は大きく変わらないため参考になると思われます。

myhomenwlab.hatenablog.com

前提情報

MS365のテナント情報は予め控えておいてください。

Microsoft Azure Portalから、メニュー: Azure Active Directory > Overview に移動すると Tenant IDPrimary domain の確認が可能です。

MS365のテナント情報の確認

設定方法

設定の概要

SSLOでの設定要素はService, Service Chain, Security Policyとなります。 ただし、Security PolicyでMS365のURLを条件に指定する必要があるため、事前にURL CategoriesにMS365のURL情報の格納が必要になります。

MS365テナント制限の設定要素

設定のデフォルト名称で Office 365 を意味する O365 の略称が設定名の一部として使用されている箇所がありました。ですが、昨今の Microsoft 365 へのブランド変更に合わせて MS365 の略称に統一しています。
また、Tenant Restrictionは表す設定名称としてTRの略称を使用しています。

Microsoft 365向けURL Categoriesの作成

Web UI と tmsh コマンドの2通りの設定パターンを紹介します。

Web UIからのURL Categoriesの作成

  • Web UIからの場合は、メニュー: Access > Secure Web Gateway > URL Categories の画面に移動して Create ボタンを押下します。

    Web UIからのURL Categoriesの作成 #1

  • Name には任意の名称を指定します。本記事ではMicrosoft 365 Tenant Restrictionの意味を含めるために MS365_TR としています。
    Associated URLs には Glob Pattern Match のチェックを外した上で下記のURLを Add ボタンで追加します。

    https://login.microsoftonline.com/
    https://login.microsoftonline.com
    https://login.microsoft.com/
    https://login.microsoft.com
    https://login.windows.net/
    https://login.windows.net
    

    Web UIからのURL Categoriesの作成 #2

  • URL Categoriesの設定が完了すると Custom Categories の配下に表示されます。

    Web UIからのURL Categoriesの作成 #3

tmsh コマンドからのURL Categoriesの作成

  • tmsh コマンドで作成する場合は、下記のコマンドを実行します。
tmsh create sys url-db url-category MS365_TR { display-name MS365_TR urls add { https://login.microsoft.com { } https://login.microsoft.com/ { } https://login.microsoftonline.com { } https://login.microsoftonline.com/ { } https://login.windows.net { } https://login.windows.net/ { } } }

tmsh list sys url-db url-category MS365_TR

tmsh save sys config partitions all
  • tmsh コマンドで設定した際の list サブ コマンドの表示例を記載します。
[root@bigip01:Active:In Sync] config # tmsh list sys url-db url-category MS365_TR
sys url-db url-category MS365_TR {
    cat-id 0
    cat-number 1904
    display-name MS365_TR
    f5-id 17004
    is-custom true
    urls {
        https://login.microsoft.com { }
        https://login.microsoft.com/ { }
        https://login.microsoftonline.com { }
        https://login.microsoftonline.com/ { }
        https://login.windows.net { }
        https://login.windows.net/ { }
    }
}
[root@bigip01:Active:In Sync] config # 

SSLO設定前の設定同期

  • 冗長化構成の場合はSSLOの設定に入る前にConfigSyncを行ってください。

    冗長構成時はSSLOの設定変更前にConfigSyncの実行

SSLOの対象設定への移動

  • メニュー: SSL Orchestrator > Configuration に移動して、対象の L3 Explicit Proxy の設定を開きます。

    SSLOの対象設定への移動

Serviceの作成

  • Service の画面に移動して Add Service を押下します。

    Serviceの作成 #1

  • F5 タブを開いて Office 365 Tenant Restrictionsダブル クリックします。タイル アイコンを押下するだけでは Office 365 Tenant Restrictions の設定画面に入れないので注意してください。

    Serviceの作成 #2

  • Office 365 Tenant Restrictions の設定画面で、下記の例を参考に各自のテナント情報を指定します。

    設定箇所 例示用の設定値 備考
    Name MS365_TR (ssloS_MS365_TR) Serviceを識別するための任意の名称を指定します。デフォルトは O365_TR になります。
    Restrict Access To Tenant samplecorp.test 適切なドメインに変更してください。
    Restrict Access Context XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX 適切なTenant IDに変更してください。

    Serviceの作成 #3

  • 設定を終えたら保存 (Save)してService Chainの設定に進みます。

Service Chainへの Office 365 Tenant Restrictions (Service) の登録

  • Service Chain の画面に移動して Add を押下します。

    Service Chainへの Office 365 Tenant Restrictions (Service) の登録 #1

  • Service Chain Properties の設定画面で下記のように設定します。

    設定箇所 例示用の設定値 備考
    Name MS365_TR_SC (ssloSC_MS365_TR_SC) Service Chainを識別するための任意の名称を指定します。
    Services の Selected Service Chain Order ssloS_MS365_TR 事前に作成したServiceを指定します。

    Service Chainへの Office 365 Tenant Restrictions (Service) の登録 #2

  • 設定を終えたら保存 (Save)してSecurity Policyの設定に進みます。

Security Policyへのルールの追加

  • Security Policy の画面に移動して RulesAdd を押下します。

    Security Policyへのルールの追加 #1

  • 下記のようにRuleを追加します。

    設定箇所 例示用の設定値 備考
    Name MS365_TR Ruleを識別するための任意の名称を指定します。
    Conditions Category Lookup (SNI) is MS365_TR 事前に作成したURL Categoriesの MS365_TR を指定して、MS365宛の通信を対象にします。
    Action Allow デフォルト値のままです。
    SSL Proxy Action Intercept MS365テナント制限用のHTTP Headerを追加できるように、暗号化通信を復号化します。
    Service Chain ssloSC_MS365_TR_SC 事前に作成したService Chainを指定します。

    MS365宛の通信をURL Categories: MS365_TR で識別した上でSSL復号化 (Intercept)の対象とし、Service Chain: ssloSC_MS365_TR_SC でMS365テナント制限をかけます。

    Security Policyへのルールの追加 #2

  • Ruleの追加後は下記の設定画面のようになります。

    Security Policyへのルールの追加 #3

  • 一連の設定が完了したら、設定を保存 (Save)した上Deploy ボタンを押下します。

    Security Policyへのルールの追加 #4

    Security Policyへのルールの追加 #5

SSLOでデプロイ後の設定同期

  • 冗長化構成の場合はSSLOのデプロイ後にConfigSyncを行ってください。

    冗長構成時はSSLOでデプロイ後にConfigSyncの実行

MS365テナント制限の確認

  • 実際にMS365テナント制限にヒットするか確認します。筆者の場合はアクセスを許可していないテナントに接続したため Error: AADSTS500021 が表示されました。

    MS365テナント制限の確認

    learn.microsoft.com

    Error Description
    AADSTS500021 Access to '{tenant}' tenant is denied. AADSTS500021 indicates that the tenant restriction feature is configured and that the user is trying to access a tenant that isn't in the list of allowed tenants specified in the header Restrict-Access-To-Tenant. For more information, see Use tenant restrictions to manage access to SaaS cloud applications.


SSLOの内部的な挙動 (SSLOがデプロイする設定群)

ここからは設定に関する理解を促すための情報を記載します。

SSLOでデプロイした設定はBIG-IPの標準機能として設定されるため、トラブルシューティングを行う際にどのようなデプロイされたか理解しておくのが重要となります。

今回のMS365テナント制限の場合は、Security Policyで設定を行ったのでPer-Request Policyにデプロイされた設定から内部実装を追えます。

Per-Request Policy上では Service ConnectのItemからConnector Profileを呼び出しており、そのConnector Profileの Entry Virtual Server でMS365テナント制限用のVirtual Serverに向けています。 そして、MS365テナント制限用のVirtual ServerにはiRulesでHTTP Headerを書き換える制御が実装されています。

MS365テナント制限の標準機能としての設定要素

MS365向けの通信はVirtual Serverのホップ数が1段増えるため、通信フローの変更に留意してください。 なお、Forward Proxy構成の基本形の通信フローに関しては下記の記事にまとめているので適宜参照してください。

myhomenwlab.hatenablog.com

ここからは実際の設定画面を見ながら、設定の構成要素を追っていきます。

SSLOからデプロイされたPer-Request Policyは下記の画面キャプチャのようになります。 Service ConnectのItemはConnector Profileを呼び出す設定になっています。

Per-Session Policyの制御フローの確認 (SSLOのSecurity Policyからデプロイされた内容の確認)

Per-Request PolicyのService Connect (Connector Profile)の確認

該当のConnector Profileでは Entry Virtual Server の設定でVirtual Serverを指定しているのが確認できます。

Connector ProfileのEntry Virtual Server設定の確認

Entry Virtual Server で指定されているのはMS365テナント制限用のVirtual Serverであり、TypeInternal となっております。

MS365テナント制限用のVirtual ServerのProperties設定 (Type, Source Addressの確認)

Type: Internal のVirtual Serverは下記のドキュメントを見るとService Chainingで使用されるICAP向けの設定のようです。

Overview of BIG-IP virtual server types (12.x - 17.x)
https://my.f5.com/manage/s/article/K55185917

Virtual server type Description of virtual server type
Internal An Internal virtual server enables usage of Internet Content Adaptation Protocol (ICAP) servers to modify HTTP requests and responses by creating and applying an ICAP profile and adding Request Adapt or Response Adapt profiles to the virtual server. For information about the Internal virtual server, refer to K15819: Overview of the internal virtual server.

MS365テナント制限用のVirtual ServerにはHTTP Headerを書き換えるiRulesが紐付いています。

MS365テナント制限用のVirtual ServerのResoures設定 (紐付いているiRulesの確認)

MS365テナント制限用のiRulesの確認

補足情報ですが、Service ConnectのItemと、Connector Profileは主にSSLOで使用される設定のようです。

APMのVPE (Visual Policy Editor)のItemであるService Connectは、下記のドキュメントに情報がありました。

techdocs.f5.com

About Service Connect
This agent, used primarily by SSLO, allows you to connect to SSLO services that were previously configured. Service Connect provides the option to attach a Connector profile to the virtual server to enable service chaining in a per-request policy.

Connector Profileは下記のドキュメントに情報がありました。

Overview of the Standard virtual server
https://support.f5.com/csp/article/k93017176

Setting Description Notes
Connector Profile A connector profile is associated with a virtual server for a service and defines the type of external service and the virtual servers that talk to the external service. This profile lets you specify the entry virtual server, which is a virtual server of type Internal, for each external service. This can be used for service chaining, for example in F5 SSL Orchestrator. Connector Profile: Local Traffic > Profiles > Other > Connector. Introduced in BIG-IP 14.0.0

情報源

公式ドキュメントの Setup ページ配下には、Features and Terminologies に新機能として Office 365 Tenant Restrictions as a service の説明はあるものの設定方法に関する記載はありませんでした。(2023年01月頃)

techdocs.f5.com

そのため、DevCentralの下記のコミュニティ記事を参考に設定方法を割り出しました。 大きな差異としては Generic ICAP Service の設定個所が Office 365 Tenant Restrictions に変わります。

community.f5.com

SSLOは公式ドキュメント上に情報がなくて、検証するかサポートに問い合わせないと不明瞭な点が多々見受けられるので留意してください。