共用方式為


服務端點驗證配置

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

瞭解如何在呼叫外部端點時,在 HTTP 要求標頭中設定認證。 Azure DevOps 接著可以使用認證連線到外部服務。 Azure DevOps 支援一組封閉的驗證配置,可供自定義服務端點類型使用。 Azure DevOps 會解譯任何自定義端點中使用的驗證配置, 並支援與外部服務的連線。

請參閱下列屬於已關閉集合的驗證配置。

提示

請參閱使用 Azure DevOps 擴充功能 SDK 進行擴充功能開發的最新檔。

基本驗證

這個設定接受兩個輸入 - 使用者名稱和密碼 (機密)

使用的默認驗證標頭為:“Basic {{ #base64 endpoint.username ”:“ endpoint.password }}”

{
    "id": "endpoint-auth-scheme-basic",
    "description": "Basic Authentication based endpoint authentication scheme",
    "type": "ms.vss-endpoint.service-endpoint-type",
    "targets": [
        "ms.vss-endpoint.endpoint-types"
    ],
    "properties": {
        "name": "UsernamePassword",
        "displayName": "i18n:Basic Authentication",
        "authenticationSchemes": [
            {
                "type": "ms.vss-endpoint.endpoint-auth-scheme-basic",
                "headers": [
                    {
                        "name": "Authorization",
                        "value": "Basic {{ #base64 endpoint.username \":\" endpoint.password }}"
                    }
                ],
                "inputDescriptors": [
                    {
                        "id": "username",
                        "name": "i18n:Username",
                        "description": "i18n:Username for connecting to the endpoint",
                        "inputMode": "textbox",
                        "isConfidential": false,
                        "validation": {
                            "isRequired": true,
                            "dataType": "string",
                             "maxLength": 300
                        }
                    },
                    {   
                        "id": "password",
                        "name": "i18n:Password",
                        "description": "i18n:Password for connecting to the endpoint",
                        "inputMode": "passwordbox",
                        "isConfidential": true,
                        "validation": {
                            "isRequired": true,
                            "dataType": "string",
                            "maxLength": 300
                        }
                    }
                ]
            }
        ]
    }
}

權杖型驗證

這個設定接受輸入 - API 令牌 (機密)

使用的默認驗證標頭為: {{endpoint.apitoken}}

{
    "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
                        }
                    }
                ]
            }
        ]
    }
}

憑證型驗證

這個設定接受輸入 - 憑證(機密)

憑證的值必須在文字區域中提供。

{
    "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"
    }
}