在 Azure 逻辑应用中使用 HTTPS 终结点调用、触发或嵌套逻辑应用Call, trigger, or nest logic apps by using HTTPS endpoints in Azure Logic Apps
若要使逻辑应用可通过 URL 调用,以便逻辑应用能够从其他服务接收传入请求,你可以在逻辑应用上使用基于请求的触发器以原生方式公开同步 HTTPS 终结点。To make your logic app callable through a URL and able to receive inbound requests from other services, you can natively expose a synchronous HTTPS endpoint by using a request-based trigger on your logic app. 使用此功能可以从其他逻辑应用调用逻辑应用,并创建一种可调用终结点的模式。With this capability, you can call your logic app from other logic apps and create a pattern of callable endpoints. 若要设置可调用终结点来处理传入调用,可以使用以下任意一种触发器类型:To set up a callable endpoint for handling inbound calls, you can use any of these trigger types:
- 请求Request
- HTTP WebhookHTTP Webhook
- 采用 ApiConnectionWebhook 类型并可接收传入 HTTPS 请求的托管连接器触发器Managed connector triggers that have the ApiConnectionWebhook type and can receive inbound HTTPS requests
本文介绍如何使用请求触发器在逻辑应用上创建可调用终结点,以及从另一个逻辑应用调用该终结点。This article shows how to create a callable endpoint on your logic app by using the Request trigger and call that endpoint from another logic app. 所有原理均完全适用于可用于接收传入请求的其他触发器类型。All principles apply identically to the other trigger types that you can use to receive inbound requests.
有关发往逻辑应用的入站调用(例如传输层安全性(TLS,以前称为安全套接字层 (SSL))或 Azure Active Directory 开放式身份验证 (Azure AD OAuth))的加密、安全性和授权的信息,请参阅保护访问和数据 - 对基于请求的触发器的入站调用的访问。For information about encryption, security, and authorization for inbound calls to your logic app, such as Transport Layer Security (TLS), previously known as Secure Sockets Layer (SSL), or Azure Active Directory Open Authentication (Azure AD OAuth), see Secure access and data - Access for inbound calls to request-based triggers.
先决条件Prerequisites
Azure 帐户和订阅。An Azure account and subscription. 如果没有 Azure 订阅,请注册试用版订阅。If you don't have a subscription, sign up for a Trial Subscription.
你要在其中使用触发器来创建可调用终结点的逻辑应用。The logic app where you want to use the trigger to create the callable endpoint. 可以从一个空白的逻辑应用着手,也可以从可在其中替换当前触发器的现有逻辑应用着手。You can start with either a blank logic app or an existing logic app where you can replace the current trigger. 本示例以空白的逻辑应用着手。This example starts with a blank logic app. 如果你不熟悉逻辑应用,请参阅什么是 Azure 逻辑应用和快速入门:创建第一个逻辑应用。If you're new to logic apps, see What is Azure Logic Apps and Quickstart: Create your first logic app.
创建可调用的终结点Create a callable endpoint
登录到 Azure 门户。Sign in to the Azure portal. 在逻辑应用设计器中创建并打开一个空白逻辑应用。Create and open a blank logic app in the Logic App Designer.
在搜索框下,选择“内置”。Under the search box, select Built-in. 在搜索框中,输入
request
作为筛选器。In the search box, enterrequest
as your filter. 在触发器列表中,选择“当收到 HTTP 请求时”。From the triggers list, select When a HTTP request is received.(可选)在“请求正文 JSON 架构”框中,可以输入一个 JSON 架构,用于描述预期该触发器要接收的有效负载或数据。Optionally, in the Request Body JSON Schema box, you can enter a JSON schema that describes the payload or data that you expect the trigger to receive.
设计器将使用此架构来生成表示触发器输出的标记。The designer uses this schema to generate tokens that represent trigger outputs. 然后,可以在逻辑应用的整个工作流中轻松引用这些输出。You can then easily reference these outputs throughout your logic app's workflow. 详细了解从 JSON 架构生成的标记。Learn more about tokens generated from JSON schemas.
对于本示例,请输入以下架构:For this example, enter this schema:
{ "type": "object", "properties": { "address": { "type": "object", "properties": { "streetNumber": { "type": "string" }, "streetName": { "type": "string" }, "town": { "type": "string" }, "postalCode": { "type": "string" } } } } }
或者,可以通过提供示例有效负载来生成 JSON 架构:Or, you can generate a JSON schema by providing a sample payload:
在“请求”触发器中,选择“使用示例有效负载生成架构”。 In the Request trigger, select Use sample payload to generate schema.
在“输入或粘贴示例 JSON 有效负载”框中输入示例有效负载,例如:In the Enter or paste a sample JSON payload box, enter your sample payload, for example:
{ "address": { "streetNumber": "00000", "streetName": "AnyStreet", "town": "AnyTown", "postalCode": "11111-1111" } }
准备就绪后,选择“完成”。When you're ready, select Done.
“请求正文 JSON 架构”框现在会显示生成的架构。The Request Body JSON Schema box now shows the generated schema.
保存逻辑应用。Save your logic app.
“HTTP POST URL”框现在会显示生成的回叫 URL,其他服务可以使用该 URL 来调用和触发逻辑应用。The HTTP POST URL box now shows the generated callback URL that other services can use to call and trigger your logic app. 此 URL 包含查询参数,这些参数指定了用于身份验证的共享访问签名 (SAS) 密钥。This URL includes query parameters that specify a Shared Access Signature (SAS) key, which is used for authentication.
若要复制回叫 URL,可以使用以下选项:To copy the callback URL, you have these options:
在“HTTP POST URL”框的右侧,选择“复制 URL”(复制文件图标)。To the right of the HTTP POST URL box, select Copy Url (copy files icon).
发出以下 POST 调用:Make this POST call:
POST https://management.chinacloudapi.cn/{logic-app-resource-ID}/triggers/{endpoint-trigger-name}/listCallbackURL?api-version=2016-06-01
从逻辑应用的“概览”窗格中复制回叫 URL。Copy the callback URL from your logic app's Overview pane.
在逻辑应用的菜单中,选择“概述”。On your logic app's menu, select Overview.
在“摘要”部分,选择“查看触发器历史记录”。 In the Summary section, select See trigger history.
在“回调 URL [POST]”下,复制 URL:Under Callback url [POST], copy the URL:
选择预期的请求方法Select expected request method
默认情况下,“请求”触发器预期的是 POST 请求。By default, the Request trigger expects a POST request. 你可以指定预期的其他方法,但只能指定一种方法。You can specify a different method to expect, but only a single method.
在“请求”触发器中打开“添加新参数”列表,然后选择“方法”,将此属性添加到触发器中。 In the Request trigger, open the Add new parameter list, and select Method, which adds this property to the trigger.
在“方法”列表中,选择触发器所应当预期的方法。From the Method list, select the method that the trigger should expect instead. 或者,可以指定自定义方法。Or, you can specify a custom method.
例如,选择“GET”方法,以便稍后可以测试终结点的 URL。For example, select the GET method so that you can test your endpoint's URL later.
通过终结点 URL 传递参数Pass parameters through endpoint URL
如果希望通过终结点的 URL 接受参数值,可以使用以下选项:When you want to accept parameter values through the endpoint's URL, you have these options:
通过 GET 参数接受值,或者通过 URL 参数接受值。Accept values through GET parameters or URL parameters.
这些值在终结点的 URL 中作为名称/值对传递。These values are passed as name-value pairs in the endpoint's URL. 对于此选项,你需要在请求触发器中使用 GET 方法。For this option, you need to use the GET method in your Request trigger. 在后续操作中,可以通过在表达式中使用
triggerOutputs()
函数,在触发器输出中获取参数值。In a subsequent action, you can get the parameter values as trigger outputs by using thetriggerOutputs()
function in an expression.通过相对路径接受值,适用于“请求”触发器中的参数。Accept values through a relative path for parameters in your Request trigger.
这些值通过终结点 URL 中的相对路径传递。These values are passed through a relative path in the endpoint's URL. 你还需要显式选择触发器预期的方法。You also need to explicitly select the method that the trigger expects. 在后续操作中,可以通过直接引用触发器输出,在这些输出中获取参数值。In a subsequent action, you can get the parameter values as trigger outputs by referencing those outputs directly.
通过 GET 参数接受值Accept values through GET parameters
在“请求”触发器中,打开“添加新参数”列表,将“方法”属性添加到触发器,然后选择“GET”方法。 In the Request trigger, open the Add new parameter list, add the Method property to the trigger, and select the GET method.
有关详细信息,请参阅选择预期的请求方法。For more information, see Select expected request method.
在“请求”触发器下,添加要在其中使用参数值的操作。Under the Request trigger, add the action where you want to use the parameter value. 对于此示例,请添加“响应”操作。For this example, add the Response action.
在“请求”触发器下,选择“新建步骤” > “添加操作”。 Under the Request trigger, select New step > Add an action.
在“选择操作”下的搜索框中,输入
response
作为筛选器。Under Choose an action, in the search box, enterresponse
as your filter. 在操作列表中选择“响应”操作。From the actions list, select the Response action.
若要构建检索参数值的
triggerOutputs()
表达式,请执行以下步骤:To build thetriggerOutputs()
expression that retrieves the parameter value, follow these steps:在“响应”操作的“正文”属性中单击,以显示动态内容列表,然后选择“表达式”。Click inside the Response action's Body property so that the dynamic content list appears, and select Expression.
在“表达式”框中,输入此表达式,将
parameter-name
替换为你的参数名称,然后选择“确定”。In the Expression box, enter this expression, replacingparameter-name
with your parameter name, and select OK.triggerOutputs()['queries']['parameter-name']
在“正文”属性中,表达式将解析为
triggerOutputs()
标记。In the Body property, the expression resolves to thetriggerOutputs()
token.如果你保存逻辑应用,请通过导航方式离开设计器,然后返回到设计器,该标记将显示你指定的参数名称,例如:If you save the logic app, navigate away from the designer, and return to the designer, the token shows the parameter name that you specified, for example:
在代码视图中,“正文”属性显示在“响应”操作的定义中,如下所示:In code view, the Body property appears in the Response action's definition as follows:
"body": "@{triggerOutputs()['queries']['parameter-name']}",
例如,假设你要为名为
postalCode
的参数传递值。For example, suppose that you want to pass a value for a parameter namedpostalCode
. “正文”属性指定带尾随空格的字符串Postal Code:
,后跟相应的表达式:The Body property specifies the string,Postal Code:
with a trailing space, followed by the corresponding expression:
若要测试可调用终结点,请从“请求”触发器中复制回叫 URL,并将该 URL 粘贴到另一个浏览器窗口中。To test your callable endpoint, copy the callback URL from the Request trigger, and paste the URL into another browser window. 在 URL 中,按以下格式将问号 (
?
) 后面的参数名称和值添加到 URL,然后按 Enter。In the URL, add the parameter name and value following the question mark (?
) to the URL in the following format, and press Enter....?{parameter-name=parameter-value}&api-version=2016-10-01...
https://prod-07.chinanorth.logic.azure.cn:433/workflows/{logic-app-resource-ID}/triggers/manual/paths/invoke?{parameter-name=parameter-value}&api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={shared-access-signature}
浏览器将返回包含以下文本的响应:
Postal Code: 123456
The browser returns a response with this text:Postal Code: 123456
若要将参数名称和值置于 URL 中的不同位置,请确保使用与号 (
&
) 作为前缀,例如:To put the parameter name and value in a different position within the URL, make sure to use the ampersand (&
) as a prefix, for example:...?api-version=2016-10-01&{parameter-name=parameter-value}&...
此示例显示了示例参数名称和值
postalCode=123456
位于 URL 中的不同位置的回叫 URL:This example shows the callback URL with the sample parameter name and valuepostalCode=123456
in different positions within the URL:第 1 个位置:
https://prod-07.chinanorth.logic.azure.cn:433/workflows/{logic-app-resource-ID}/triggers/manual/paths/invoke?postalCode=123456&api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={shared-access-signature}
1st position:https://prod-07.chinanorth.logic.azure.cn:433/workflows/{logic-app-resource-ID}/triggers/manual/paths/invoke?postalCode=123456&api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={shared-access-signature}
第 2 个位置:
https://prod-07.chinanorth.logic.azure.cn:433/workflows/{logic-app-resource-ID}/triggers/manual/paths/invoke?api-version=2016-10-01&postalCode=123456&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={shared-access-signature}
2nd position:https://prod-07.chinanorth.logic.azure.cn:433/workflows/{logic-app-resource-ID}/triggers/manual/paths/invoke?api-version=2016-10-01&postalCode=123456&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={shared-access-signature}
备注
若要在 URI 中包含哈希符号或井号 ( # ),请改用以下编码版本:%25%23
If you want to include the hash or pound symbol (#) in the URI, use this encoded version instead: %25%23
通过相对路径接受值Accept values through a relative path
在“请求”触发器中打开“添加新参数”列表,然后选择“相对路径”,将此属性添加到触发器中。 In the Request trigger, open the Add new parameter list, and select Relative path, which adds this property to the trigger.
在“相对路径”属性中,指定希望 URL 接受的 JSON 架构中参数的相对路径,例如
/address/{postalCode}
。In the Relative path property, specify the relative path for the parameter in your JSON schema that you want your URL to accept, for example,/address/{postalCode}
.在“请求”触发器下,添加要在其中使用参数值的操作。Under the Request trigger, add the action where you want to use the parameter value. 对于此示例,请添加“响应”操作。For this example, add the Response action.
在“请求”触发器下,选择“新建步骤” > “添加操作”。 Under the Request trigger, select New step > Add an action.
在“选择操作”下的搜索框中,输入
response
作为筛选器。Under Choose an action, in the search box, enterresponse
as your filter. 在操作列表中选择“响应”操作。From the actions list, select the Response action.
在响应操作的“正文”属性中,包含表示在触发器相对路径中指定的参数的标记。In the Response action's Body property, include the token that represents the parameter that you specified in your trigger's relative path.
例如,假设你希望“响应”操作返回
Postal Code: {postalCode}
。For example, suppose that you want the Response action to returnPostal Code: {postalCode}
.请在“正文”属性中,输入
Postal Code:
和一个尾部空格。In the Body property, enterPostal Code:
with a trailing space. 将光标停留在编辑框内,使动态内容列表保持打开状态。Keep your cursor inside the edit box so that the dynamic content list remains open.在动态内容列表中,从“收到 HTTP 请求时”部分选择“postalCode”标记。In the dynamic content list, from the When a HTTP request is received section, select the postalCode token.
“正文”属性现在包含选定的参数:The Body property now includes the selected parameter:
保存逻辑应用。Save your logic app.
在“请求”触发器中,回叫 URL 已更新,现在包含相对路径,例如:In the Request trigger, the callback URL is updated and now includes the relative path, for example:
https://prod-07.chinanorth.logic.azure.cn/workflows/{logic-app-resource-ID}/triggers/manual/paths/invoke/address/{postalCode}?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig={shared-access-signature}
若要测试可调用终结点,请从“请求”触发器中复制更新的回叫 URL,并将该 URL 粘贴到另一个浏览器窗口中,将 URL 中的
{postalCode}
替换为123456
,然后按 Enter。To test your callable endpoint, copy the updated callback URL from the Request trigger, paste the URL into another browser window, replace{postalCode}
in the URL with123456
, and press Enter.浏览器将返回包含以下文本的响应:
Postal Code: 123456
The browser returns a response with this text:Postal Code: 123456
备注
若要在 URI 中包含哈希符号或井号 ( # ),请改用以下编码版本:
%25%23
If you want to include the hash or pound symbol (#) in the URI, use this encoded version instead:%25%23
通过终结点 URL 调用逻辑应用Call logic app through endpoint URL
创建终结点后,可以通过将 HTTPS POST
请求发送到终结点的完整 URL 来触发逻辑应用。After you create the endpoint, you can trigger the logic app by sending an HTTPS POST
request to the endpoint's full URL. 逻辑应用对直接访问终结点提供内置支持。Logic apps have built-in support for direct-access endpoints.
从架构生成的标记Tokens generated from schema
在“请求”触发器中提供 JSON 架构时,逻辑应用设计器会在该架构中生成属性的标记。When you provide a JSON schema in the Request trigger, the Logic App Designer generates tokens for the properties in that schema. 然后,可以使用这些令牌通过逻辑应用工作流传递数据。You can then use those tokens for passing data through your logic app workflow.
例如,如果将其他属性(例如 "suite"
)添加到 JSON 架构,则可以在逻辑应用的后续步骤中使用这些属性的标记。For example, if you add more properties, such as "suite"
, to your JSON schema, tokens for those properties are available for you to use in the later steps for your logic app. 下面是完整的 JSON 架构:Here is the complete JSON schema:
{
"type": "object",
"properties": {
"address": {
"type": "object",
"properties": {
"streetNumber": {
"type": "string"
},
"streetName": {
"type": "string"
},
"suite": {
"type": "string"
},
"town": {
"type": "string"
},
"postalCode": {
"type": "string"
}
}
}
}
}
创建嵌套的逻辑应用Create nested logic apps
通过添加可接收请求的其他逻辑应用,可以在逻辑应用中嵌套工作流。You can nest workflows in your logic app by adding other logic apps that can receive requests. 若要包含这些逻辑应用,请执行以下步骤:To include these logic apps, follow these steps:
在要调用另一个逻辑应用的步骤下,选择“新建步骤” > “添加操作”。 Under the step where you want to call another logic app, select New step > Add an action.
在“选择操作”下,选择“内置”。 Under Choose an action, select Built-in. 在搜索框中,输入
logic apps
作为筛选器。In the search box, enterlogic apps
as your filter. 在操作列表中,选择“选择逻辑应用工作流”。From the actions list, select Choose a Logic Apps workflow.设计器将显示可供选择的逻辑应用。The designer shows the eligible logic apps for you to select.
选择要从当前逻辑应用调用的逻辑应用。Select the logic app to call from your current logic app.
引用传入请求中的内容Reference content from an incoming request
如果传入请求的内容类型为 application/json
,则可以在传入请求中引用属性。If the incoming request's content type is application/json
, you can reference the properties in the incoming request. 否则,此内容被视为可以传递给其他 API 的单个二进制单元。Otherwise, this content is treated as a single binary unit that you can pass to other APIs. 若要在逻辑应用的工作流内部引用此内容,首先需要转换此内容。To reference this content inside your logic app's workflow, you need to first convert that content.
例如,如果传递 application/xml
类型的内容,可以使用 @xpath()
表达式执行 XPath 提取,或使用 @json()
表达式将 XML 转换为 JSON。For example, if you're passing content that has application/xml
type, you can use the @xpath()
expression to perform an XPath extraction, or use the @json()
expression for converting XML to JSON. 详细了解如何处理支持的内容类型。Learn more about working with supported content types.
若要从传入请求中获取输出,可以使用 @triggerOutputs
表达式。To get the output from an incoming request, you can use the @triggerOutputs
expression. 例如,假设输出如以下示例所示:For example, suppose you have output that looks like this example:
{
"headers": {
"content-type" : "application/json"
},
"body": {
"myProperty" : "property value"
}
}
若要专门访问 body
属性,可以使用 @triggerBody()
表达式作为快捷方式。To access specifically the body
property, you can use the @triggerBody()
expression as a shortcut.
对请求的响应Respond to requests
有时,你希望通过向调用方返回内容,对触发逻辑应用的某些请求做出响应。Sometimes you want to respond to certain requests that trigger your logic app by returning content to the caller. 若要构造响应的状态代码、标头和正文,请使用“响应”操作。To construct the status code, header, and body for your response, use the Response action. 此操作可以出现在逻辑应用中的任何位置,而不仅仅是工作流的末尾。This action can appear anywhere in your logic app, not just at the end of your workflow. 如果逻辑应用不包含“响应”操作,则终结点会 立即 以“202 已接受”状态进行响应。If your logic app doesn't include a Response action, the endpoint responds immediately with the 202 Accepted status.
要使原始调用方能够成功获取响应,除非调用用作嵌套逻辑应用的已触发逻辑应用,否则响应所需的所有步骤必须在请求超时限制内完成。For the original caller to successfully get the response, all the required steps for the response must finish within the request timeout limit unless the triggered logic app is called as a nested logic app. 如果在此限制时间内未返回响应,传入请求将会超时,并收到“408 客户端超时”响应。If no response is returned within this limit, the incoming request times out and receives the 408 Client timeout response.
对于嵌套逻辑应用,父逻辑应用会继续等待响应,直到所有步骤已完成,而不考虑所需的时间。For nested logic apps, the parent logic app continues to wait for a response until all the steps are completed, regardless of how much time is required.
构造响应Construct the response
在响应正文中,可以包含多个标头和任意类型的内容。In the response body, you can include multiple headers and any type of content. 例如,此响应的标头指定响应的内容类型为 application/json
,并指定正文包含 town
和 postalCode
属性的值,这些值基于本主题前面所述的“请求”触发器的 JSON 架构。For example, this response's header specifies that the response's content type is application/json
and that the body contains values for the town
and postalCode
properties, based on the JSON schema described earlier in this topic for the Request trigger.
响应具有以下属性:Responses have these properties:
属性(显示值)Property (Display) | 属性 (JSON)Property (JSON) | 说明Description |
---|---|---|
状态代码Status Code | statusCode |
要在传入请求的响应中使用的 HTTPS 状态代码。The HTTPS status code to use in the response for the incoming request. 该代码可以是以 2xx、4xx 或 5xx 开头的任何有效状态代码。This code can be any valid status code that starts with 2xx, 4xx, or 5xx. 但是,不允许使用 3xx 状态代码。However, 3xx status codes are not permitted. |
标头Headers | headers |
要包含在响应中的一个或多个标头One or more headers to include in the response |
正文Body | body |
正文对象,可以是字符串、JSON 对象甚至是从上一步引用的二进制内容A body object that can be a string, a JSON object, or even binary content referenced from a previous step |
若要查看“响应”操作的 JSON 定义以及逻辑应用的完整 JSON 定义,请在逻辑应用设计器工具栏上选择“代码视图”。To view the JSON definition for the Response action and your logic app's complete JSON definition, on the Logic App Designer toolbar, select Code view.
"Response": {
"type": "Response",
"kind": "http",
"inputs": {
"body": {
"postalCode": "@triggerBody()?['address']?['postalCode']",
"town": "@triggerBody()?['address']?['town']"
},
"headers": {
"content-type": "application/json"
},
"statusCode": 200
},
"runAfter": {}
}
问题解答Q & A
问:URL 的安全性如何?Q: What about URL security?
答:Azure 使用 共享访问签名 (SAS) 安全生成逻辑应用回调 URL。A: Azure securely generates logic app callback URLs by using Shared Access Signature (SAS). 此签名以查询参数的形式传递,在运行逻辑应用之前必须先验证此签名。This signature passes through as a query parameter and must be validated before your logic app can run. Azure 使用每个逻辑应用的机密密钥、触发器名称和执行的操作的唯一组合生成签名。Azure generates the signature using a unique combination of a secret key per logic app, the trigger name, and the operation that's performed. 因此,除非用户对机密逻辑应用密钥拥有访问权限,否则他们无法生成有效的签名。So unless someone has access to the secret logic app key, they cannot generate a valid signature.
重要
对于生产系统和安全性较高的系统,强烈建议不要直接从浏览器中调用逻辑应用,原因如下:For production and higher security systems, we strongly advise against calling your logic app directly from the browser for these reasons:
- URL 中会出现共享访问密钥。The shared access key appears in the URL.
- 由于域在 Azure 逻辑应用客户之间共享,你将无法管理安全内容策略。You can't manage security content policies due to shared domains across Azure Logic Apps customers.
问:是否可以进一步配置可调用终结点?Q: Can I configure callable endpoints further?
答:可以,HTTPS 终结点支持通过 Azure API 管理进行更高级的配置。A: Yes, HTTPS endpoints support more advanced configuration through Azure API Management. 此服务还提供相应的功能,使你能够以一致的方式管理所有 API(包括逻辑应用)、设置自定义域名和使用其他身份验证方法等等,例如:This service also offers the capability for you to consistently manage all your APIs, including logic apps, set up custom domain names, use more authentication methods, and more, for example:
- 更改请求方法Change the request method
- 更改请求的 URL 段Change the URL segments of the request
- 在 Azure 门户中设置 API 管理域Set up your API Management domains in the Azure portal
- 设置用于检查基本身份验证的策略。Set up policy to check for Basic authentication