Azure DevOps Services |Azure DevOps Server |Azure DevOps Server 2022
在扩展中定义自定义服务终结点类型时,指定一个身份验证方案,告知 Azure DevOps 如何在 HTTP 请求标头中设置凭据。 Azure DevOps 支持自定义终结点的以下身份验证方案。
小贴士
有关最新的扩展开发指南,包括主题处理以及从 VSS.SDK 的迁移,请参阅 Azure DevOps 扩展 SDK 开发人员门户。
基本身份验证
使用作为 Base64 编码标头发送的 Authorization 用户名和密码。
重要
尽可能使用服务主体和托管标识,而不是基本身份验证。 有关详细信息,请参阅使用服务主体和托管标识。
内置方案类型为 ms.vss-endpoint.endpoint-auth-scheme-basic. 无需在扩展清单中声明它 - 在终结点类型的 authenticationSchemes 数组中引用它:
"authenticationSchemes": [
{
"type": "ms.vss-endpoint.endpoint-auth-scheme-basic"
}
]
Azure DevOps 会提示用户输入用户名和密码,并将其作为标准 HTTP 基本Authorization标头发送。
基于令牌的身份验证
接收单个机密输入——API 令牌。 令牌值会在 Authorization 标头中发送。
{
"id": "endpoint-auth-scheme-token",
"description": "i18n:Token based endpoint authentication scheme",
"type": "ms.vss-endpoint.service-endpoint-type",
"targets": [
"ms.vss-endpoint.endpoint-types"
],
"properties": {
"name": "Token",
"displayName": "i18n:Token Based Authentication",
"authenticationSchemes": [
{
"type": "ms.vss-endpoint.endpoint-auth-scheme-token",
"headers": [
{
"name": "Authorization",
"value": "{{endpoint.apitoken}}"
}
],
"inputDescriptors": [
{
"id": "apitoken",
"name": "i18n:API Token",
"description": "i18n:API Token for connection to endpoint",
"inputMode": "textbox",
"isConfidential": true,
"validation": {
"isRequired": true,
"dataType": "string",
"maxLength": 300
}
}
]
}
]
}
}
{{endpoint.apitoken}} 占位符在运行时解析为用户在 API 令牌 字段中输入的值。
基于证书的身份验证
接收单个保密输入:在文本区域中输入的证书内容。
{
"id": "endpoint-auth-scheme-cert",
"description": "i18n:Creates a certificate-based endpoint authentication scheme",
"type": "ms.vss-endpoint.service-endpoint-type",
"targets": [
"ms.vss-endpoint.endpoint-types"
],
"properties": {
"name": "Certificate",
"displayName": "i18n:Certificate Based",
"authenticationSchemes": [
{
"type": "ms.vss-endpoint.endpoint-auth-scheme-cert",
"inputDescriptors": [
{
"id": "certificate",
"name": "i18n:Certificate",
"description": "Content of the certificate",
"inputMode": "TextArea",
"isConfidential": true,
"validation": {
"isRequired": true,
"dataType": "string"
}
}
]
}
]
}
}
无身份验证
当外部服务支持匿名访问且不需要凭据时,请使用此方案。
{
"id": "endpoint-auth-scheme-none",
"description": "i18n:Creates an endpoint authentication scheme with no authentication.",
"type": "ms.vss-endpoint.endpoint-auth-scheme-none",
"targets": [
"ms.vss-endpoint.endpoint-auth-schemes"
],
"properties": {
"name": "None",
"displayName": "i18n:No Authentication"
}
}