(2023.08.26 Sat @KLN)
(2024.06.08-10 Sat-Mon @KLN)
Entra ID
Entra ID是云身份和接入解决方案。2023年由AAD更名而来。
Azure Active Directory (AAD)是微软基于云的身份和接入管理服务(access management service)。AAD包括:
- 数据库(directory):记录用户有哪些及每个用户的权限也就是可以做什么
- 服务集(set of services):使员工可以登录(验证)和可被允许访问的IT资源(授权)。IT资源包括内部资源和外部资源,内部资源如公司内网的数据和工具,外部资源包括Microsoft 365和SaaS应用
AAD和微软的Active Directory (AD)对比
AAD运行在云端,是在微软Azure公共云平台上的独立解决方案。而AD则部署在本地(on-premises)。
- 认证协议:AD使用LDAP和Kerberos等协议,AAD使用现代化的SAML,OAuth 2.0和OpenID等。
- 组群政策(group policy):AD允许管理员管理组政策对象(group policy objects),AAD使用条件接入政策(conditional access policies)
- 域服务(domain services):AD提供了DNS, DHCP, NPS, Wi-Fi和VPN等,AAD不提供
- 用户设备管理:AAD管理接入云资源的设备,而AD主要管理本地网络中部署的设备
- B2B和B2C:AD聚焦于内部用户管理,AAD管理外部伙伴和面向用户应用的接入
- 应用整合:AAD整合了众多云服务与应用,AD聚焦(be tailored to)于本地资源
AAD与AD通常一起使用,称为混合AD环境(hybrid AD environment)。
AAD特点
- REST API:AAD使用REST(Representational State Transfer) API用于网络服务间通信
- 认证:AAD使用基于云的认证协议,如OAuth 2.0, SAML等
- 网络组织:每个AAD实例被称作房客(tenant),这是一个用户和组群的扁平结构组织
- 权利管理(entitlement management):管理员将用户分为组,可对组赋予应用和资源的接入权限
- 设备:AAD 支持对移动设备(带微软 Intune?) 的管理
- 桌面:Windows 桌面电脑可以加入 AAD 用 Microsoft Intyne(?)
- 服务器:AAD 使用 AAD域服务(domain services) 管理 Azure 环境中的服务器
Tenant
AAD 的重要概念之一是房客 tenant。AAD tenant 是 AAD 中某一公司或组织用户的特定实例。创建 tenant,仅需这个组织在微软云服务,如 office 365,中注册并提供诸如组织名称和位置等细节信息即可。初始域名以.onmicrosoft.com 结尾,无法修改或删除初始域名,但可以为 tenant 定制化域名。
每个 Azure tenant 有一个专门的 AAD directory,其中包含了 tenant 的用户,组,应用,可为 tenant 的资源执行身份和接入管理。
在网络中我们使用域的概念,与本地的 AD 域并无关系。AD 域是一并管理的由相关用户,电脑和其他 AD 对象构成的组。而 AAD 没有 AD 中的森林 forests 和组织单元 OUs.
Application Object & Service Principal
App Object
一个Entra应用被定义为该应用的唯一一个应用对象(application object),该对象贮存在其注册的tenant中,该tenant称为其home tenant。应用对象,类似于一个模版/基类,用于创建一个或多个该应用对象的实例,也就是服务主体对象(service principal object)。service principal创建于应用被用到的每个tenant。与面向对象编程中的类相似,应用对象也有一些静态属性可作用域所有子类(服务对象)。
应用对象描绘了该应用的三个角度:
- 服务如何发送token以接入该应用
- 该应用可能会使用的资源
- 该应用可以执行的动作
Service Principal
在Entra tenant中使用资源的对象被表示为security principal,该要求适用于用户(user principal)和应用(service principal)。Security principal定义了连接政策(access policy)和该用户或应用的权限,用于登录时的授权和认证。
Service principal分三类:
Application:这类service principal是全局应用对象在单tenant/directory中的本地化表达(local representation),或具体应用实例(application instance),继承了应用对象中特定属性。该service principal创建于应用被使用的tenant中,并引用全局唯一的应用对象(globally unique app object)。该service principal定义了该应用可以做什么,谁可接入该应用,以及该应用会使用哪些资源。
Service principal创建于应用被赋予权限可以使用某些资源的时候。注册应用时,service principal被自动创建。同样也可以使用Azure PowerShell,Azure CLI, Microsoft Grapph或其他工具创建。Managed Identity:This type of service principal is used to represent a managed identity. Managed identities eliminate the need for developers to manage credentials. Managed identities provide an identity for applications to use when connecting to resources that support Microsoft Entra authentication. When a managed identity is enabled, a service principal representing that managed identity is created in your tenant. Service principals representing managed identities can be granted access and permissions, but can't be updated or modified directly.
遗产:This type of service principal represents a legacy app, which is an app created before app registrations were introduced or an app created through legacy experiences. A legacy service principal can have credentials, service principal names, reply URLs, and other properties that an authorized user can edit, but doesn't have an associated app registration. The service principal can only be used in the tenant where it was created.
微软Graph Service Principal实体定义了principal object属性的schema。
可使用Enterprise applications页面管理service principals,其中包括service principal的权限,用户承诺权限(user consent permission)等信息。
Application object和service principal的关系
应用对象是所有tenants中该应用的全局表达(global representation),service principal是在特定tenant中该应用对象的局部表达(local representation)。应用对象好比一个模版,有默认属性,可用于创建service principal对象。
应用对象由如下特性:
- 与软件应用有一对一映射关系(one-to-one)
- 与衍生/对应的service principal有一对多(one-to-many)映射关系
Service principal必须在应用被使用的tenant中创建,使其可以建立一个被tenant保护的用于登录或接入资源的身份。单tenant应用(single-tenant application)只能有一个service principal,即在home tenant中,在应用注册时创建和授权(consent)。多tenant应用(multitenant application)在每个tenant中有一个service principal,在对应tenant中的用户承诺使用时创建。
App ID, Object ID and service principal ID
AAD中的一个应用注册(an app registration)会产生一个应用对象(application object)。AAD中的所有对象都有一个object ID。在访问特定的应用对象时,应使用object ID。Object ID仅在应用注册的tenant中使用,用于识别应用对象。Object ID是应用对象的独一无二的ID,是创建应用的模版和蓝图(blueprint)。
应用对象的App ID/Client ID属性可跨tenants(cross tenants)使用,可作用于多个对象类型。用处主要有二:
- 在多个登录和token流(如client_id in OAuth 2.0和OpenID连接)中用于识别应用
- 用于识别Service principal对象背后的应用对象,service principal可当做应用对象在某个tenant中的实例
Application Registration & Enterprise Application
AAD中注册的应用,一旦应用注册完成,在tenant会创建两种类型的对象:
- application object
- service principal object
App object是AAD的App registration中看到的对象,这个对象扮演了模版的角色,用户可设置其中的API权限,client secrets,品牌,app roles等。用户对app的所有这些定制都被写入app manifest file。Application object描述的应用的三个方面,如前文所提到。
Service principal object可在AAD的enterprise registration中看到。每个app object在enterprise registration中创建一个service principal object。这里的service principal可以当做application object的具体实例,且从application object继承特定属性。Service principal在tenant中创建,application也需在该tenant中使用并引用全局唯一的app object。Service principal object定义了在这个特定tenant中该app可以做什么,谁可以介入app,同埋该app可以使用哪些资源。
简单对比:App registration用于注册应用;Enterprise application用于管理这些应用的接入。
resource group
scope
Reference
1 Microsoft Azure
2 stackoverflow