Microsoft Azure : マルチテナントの際のサービスプリンシパルの設計

背景

AzureのAADでは、人間以外のアクターが認証認可を行うために、アプリケーションオブジェクトとサービスプリンシパルという2つのAADオブジェクトが用意されています。

これらのオブジェクトはMS Learnで解説の通り、2つで1セットであり、ユーザーからは不可分に見えるよう設計されています。

サービス プリンシパルについて - Learn | Microsoft Docs

サービス プリンシパルとアプリケーションは緊密にリンクされます。 アプリケーション登録が Azure AD テナントに追加されるたびに、その Azure AD テナントで "サービス プリンシパル" オブジェクトが作成されます。(略)

サービス プリンシパルを作成すると、使用するほとんどのツールでもアプリケーション登録が同時に作成されます。 そのため、2 つの異なるオブジェクトが存在することに気付かない場合があります。

Azureの公式ドキュメントでは、アプリケーションオブジェクトとサービスプリンシパルの関係性について、UMLの多重度の観点から説明しています。マルチテナント設計をする際に押さえておくべきポイントと感じたので、関連するドキュメントを読んだ際のメモを以下に残します。

多重度

図1 : AppとAppObjectとService Principle間の多重度

An application object therefore has a 1:1 relationship with the software application, and a 1:many relationship with its corresponding service principal object(s).

マルチテナント構成におけるオブジェクト同士の関係性

図2 : マルチテナント構成時のAppとAppObjectとService Principle Objectの関係性

Application ObjectはHome Tenantにのみ配備されるのに対し、Service Principle Objectはアプリケーションが使用される全てのテナントに配備される。

The application object is the global representation of your application for use across all tenants, and the service principal is the local representation for use in a specific tenant.

また、各Service Principle ObjectはApplication Objectに対する参照を持つ。

A service principal is created in each tenant where the application is used and references the globally unique app object.

Application Objectは各Service Principle Objectで共用されるプロパティ価を保持するテンプレートのように機能する。

The application object serves as the template from which common and default properties are derived for use in creating corresponding service principal objects.

関連ドキュメント

https://tech-lab.sios.jp/archives/23371

/* https://sunrise033.com/entry/hatena-blog-how-to-hierarchicalize-categories */