Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion packages/samples/specs/data-plane/widget-manager/main.tsp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ using Azure.Core.Traits;

@service(#{ title: "Contoso Widget Manager" })
@versioned(Contoso.WidgetManager.Versions)
@useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-Key">)
@useAuth(WidgetManagerApiKeyAuth | WidgetManagerOauth2Auth)
namespace Contoso.WidgetManager;

/** Authenticate requests with an API key in the X-Key header. */
model WidgetManagerApiKeyAuth is ApiKeyAuth<ApiKeyLocation.header, "X-Key">;

/** Authenticate requests with OAuth2 using the widget service scope. */
model WidgetManagerOauth2Auth
is OAuth2Auth<[
{
type: OAuth2FlowType.implicit;
authorizationUrl: "https://login.contoso.com/common/oauth2/v2.0/authorize";
scopes: ["https://widget.contoso.com/.default"];
}
]>;

@doc("The Contoso Widget Manager service version.")
enum Versions {
@doc("Version 2022-08-31")
Expand Down
Comment thread
timotheeguerin marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,29 @@
],
"security": [
{
"ApiKeyAuth": []
"WidgetManagerApiKeyAuth": []
},
{
"WidgetManagerOauth2Auth": [
"https://widget.contoso.com/.default"
]
}
],
"securityDefinitions": {
"ApiKeyAuth": {
"WidgetManagerApiKeyAuth": {
"type": "apiKey",
"description": "Authenticate requests with an API key in the X-Key header.",
"name": "X-Key",
"in": "header"
},
"WidgetManagerOauth2Auth": {
"type": "oauth2",
"description": "Authenticate requests with OAuth2 using the widget service scope.",
"flow": "implicit",
"authorizationUrl": "https://login.contoso.com/common/oauth2/v2.0/authorize",
"scopes": {
"https://widget.contoso.com/.default": ""
}
}
},
"tags": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,9 @@ paths:
schema:
$ref: '#/components/schemas/WidgetRepairRequest'
security:
- ApiKeyAuth: []
- WidgetManagerApiKeyAuth: []
- WidgetManagerOauth2Auth:
- https://widget.contoso.com/.default
components:
parameters:
Azure.Core.ClientRequestIdHeader:
Expand Down Expand Up @@ -1684,7 +1686,16 @@ components:
- SentToManufacturer
description: The repair state of a widget.
securitySchemes:
ApiKeyAuth:
WidgetManagerApiKeyAuth:
Comment thread
timotheeguerin marked this conversation as resolved.
type: apiKey
in: header
name: X-Key
description: Authenticate requests with an API key in the X-Key header.
WidgetManagerOauth2Auth:
type: oauth2
flows:
implicit:
authorizationUrl: https://login.contoso.com/common/oauth2/v2.0/authorize
scopes:
https://widget.contoso.com/.default: ''
description: Authenticate requests with OAuth2 using the widget service scope.
Loading