Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Simulates authentication and authorization using API keys or OAuth2.
Plugin instance definition
{
"name": "AuthPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "auth"
}
Configuration example: API key
{
"auth": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/authplugin.schema.json",
"type": "apiKey",
"apiKey": {
"parameters": [
{
"in": "header",
"name": "x-api-key"
},
{
"in": "query",
"name": "code"
}
],
"allowedKeys": [
"1234"
]
}
}
}
Configuration example: OAuth2
{
"auth": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/authplugin.schema.json",
"type": "oauth2",
"oauth2": {
"metadataUrl": "https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration",
"allowedApplications": [
"00000000-0000-0000-0000-000000000000"
],
"allowedAudiences": [
"00000000-0000-0000-0000-000000000000"
],
"allowedPrincipals": [
"00000000-0000-0000-0000-000000000000"
],
"allowedTenants":[
"00000000-0000-0000-0000-000000000000"
],
"issuer": "https://login.microsoftonline.com/ffffffff-eeee-dddd-cccc-bbbbbbbbbbb0/v2.0",
"scopes": [
"Posts.Read"
],
"validateLifetime": true,
"validateSigningKey": true
}
}
}
Configuration properties
| Property | Description | Required |
|---|---|---|
type |
Type of authentication and authorization that Dev Proxy should use. Allowed values: apiKey, oauth2 |
Yes |
apiKey |
Configuration for API key authentication and authorization. | Yes, when type is apiKey |
oauth2 |
Configuration for OAuth2 authentication and authorization. | Yes, when type is oauth2 |
API key configuration properties
| Property | Description | Required |
|---|---|---|
allowedKeys |
List of allowed API keys. | Yes |
parameters |
List of parameters that contain the API key. | Yes |
Parameter configuration properties
| Property | Description | Required |
|---|---|---|
in |
Where the parameter is expected to be found. Allowed values: header, query, cookie |
Yes |
name |
Name of the parameter. | Yes |
OAuth2 configuration properties
| Property | Description | Required |
|---|---|---|
metadataUrl |
URL to the OpenID Connect metadata document. | Yes |
allowedApplications |
List of allowed application IDs. Leave empty to not validate the application (appid or azp claim) for which the token is issued. |
No |
allowedAudiences |
List of allowed audiences. Leave empty to not validate the audience (aud claim) for which the token is issued. |
No |
allowedPrincipals |
List of allowed principals. Leave empty to not validate the principal (oid claim) for which the token is issued. |
No |
allowedTenants |
List of allowed tenants. Leave empty to not validate the tenant (tid claim) for which the token is issued. |
No |
issuer |
Allowed token issuer. Leave empty to not validate the token issuer. | No |
roles |
List of allowed roles. Leave empty to not validate the roles (roles claim) on the token. |
No |
scopes |
List of allowed scopes. Leave empty to not validate the scopes (scp claim) on the token. |
No |
validateLifetime |
Set to false to disable validating the token lifetime. Default true. |
No |
validateSigningKey |
Set to false to disable validating the token signature. Default true |
No |
Command line options
None
Cộng tác với chúng tôi trên GitHub
Bạn có thể tìm thấy nguồn cho nội dung này trên GitHub, nơi bạn cũng có thể tạo và xem lại các vấn đề và yêu cầu kéo. Để biết thêm thông tin, hãy xem hướng dẫn dành cho người đóng góp của chúng tôi.