@microsoft/agents-hosting 1.7.2 → 1.8.0-beta.34.g5d543f96c0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +64 -2
- package/dist/package.json +3 -3
- package/dist/src/agent-client/agentClient.d.ts +18 -6
- package/dist/src/agent-client/agentClient.js +34 -18
- package/dist/src/agent-client/agentClient.js.map +1 -1
- package/dist/src/agent-client/agentResponseHandler.d.ts +14 -9
- package/dist/src/agent-client/agentResponseHandler.js +10 -5
- package/dist/src/agent-client/agentResponseHandler.js.map +1 -1
- package/dist/src/agent-client/createAgentResponseHandler.d.ts +7 -2
- package/dist/src/agent-client/createAgentResponseHandler.js +55 -8
- package/dist/src/agent-client/createAgentResponseHandler.js.map +1 -1
- package/dist/src/app/adaptiveCards/activityValueParsers.d.ts +1 -4
- package/dist/src/app/adaptiveCards/activityValueParsers.js +2 -5
- package/dist/src/app/adaptiveCards/activityValueParsers.js.map +1 -1
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.d.ts +18 -0
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js +53 -23
- package/dist/src/app/adaptiveCards/adaptiveCardsActions.js.map +1 -1
- package/dist/src/app/agentApplication.d.ts +3 -0
- package/dist/src/app/agentApplication.js +126 -78
- package/dist/src/app/agentApplication.js.map +1 -1
- package/dist/src/app/attachmentDownloader.d.ts +4 -1
- package/dist/src/app/attachmentDownloader.js +27 -5
- package/dist/src/app/attachmentDownloader.js.map +1 -1
- package/dist/src/app/auth/handlers/agenticAuthorization.d.ts +1 -1
- package/dist/src/app/auth/handlers/azureBotAuthorization.d.ts +1 -1
- package/dist/src/app/auth/types.d.ts +3 -4
- package/dist/src/app/index.d.ts +2 -0
- package/dist/src/app/index.js.map +1 -1
- package/dist/src/app/streaming/streamingResponse.js +2 -9
- package/dist/src/app/streaming/streamingResponse.js.map +1 -1
- package/dist/src/app/teamsAttachmentDownloader.d.ts +3 -1
- package/dist/src/app/teamsAttachmentDownloader.js +12 -1
- package/dist/src/app/teamsAttachmentDownloader.js.map +1 -1
- package/dist/src/auth/authConfiguration.js +12 -0
- package/dist/src/auth/authConfiguration.js.map +1 -1
- package/dist/src/auth/index.d.ts +2 -1
- package/dist/src/auth/index.js +2 -1
- package/dist/src/auth/index.js.map +1 -1
- package/dist/src/auth/jwt-middleware.d.ts +6 -0
- package/dist/src/auth/jwt-middleware.js +263 -13
- package/dist/src/auth/jwt-middleware.js.map +1 -1
- package/dist/src/auth/msal/msalConnectionSettings.d.ts +8 -0
- package/dist/src/auth/msal/msalHttpRetryHandlerHelper.d.ts +34 -0
- package/dist/src/auth/msal/msalHttpRetryHandlerHelper.js +126 -0
- package/dist/src/auth/msal/msalHttpRetryHandlerHelper.js.map +1 -0
- package/dist/src/auth/msal/msalTokenProvider.d.ts +1 -0
- package/dist/src/auth/msal/msalTokenProvider.js +23 -14
- package/dist/src/auth/msal/msalTokenProvider.js.map +1 -1
- package/dist/src/auth/settings.d.ts +18 -0
- package/dist/src/auth/settings.js +8 -2
- package/dist/src/auth/settings.js.map +1 -1
- package/dist/src/cloudAdapter.d.ts +29 -2
- package/dist/src/cloudAdapter.js +44 -2
- package/dist/src/cloudAdapter.js.map +1 -1
- package/dist/src/errorHelper.js +137 -101
- package/dist/src/errorHelper.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +1 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/invoke/adaptiveCardInvokeValue.d.ts +5 -0
- package/dist/src/oauth/userTokenClient.d.ts +0 -1
- package/dist/src/oauth/userTokenClient.js +0 -1
- package/dist/src/oauth/userTokenClient.js.map +1 -1
- package/dist/src/observability/traces.js +3 -2
- package/dist/src/observability/traces.js.map +1 -1
- package/dist/src/outboundHostValidator.d.ts +47 -0
- package/dist/src/outboundHostValidator.js +149 -0
- package/dist/src/outboundHostValidator.js.map +1 -0
- package/dist/src/state/agentState.d.ts +5 -0
- package/dist/src/state/agentState.js +16 -3
- package/dist/src/state/agentState.js.map +1 -1
- package/package.json +3 -3
- package/src/agent-client/agentClient.ts +46 -23
- package/src/agent-client/agentResponseHandler.ts +14 -9
- package/src/agent-client/createAgentResponseHandler.ts +70 -9
- package/src/app/adaptiveCards/activityValueParsers.ts +3 -9
- package/src/app/adaptiveCards/adaptiveCardsActions.ts +52 -24
- package/src/app/agentApplication.ts +135 -74
- package/src/app/attachmentDownloader.ts +25 -5
- package/src/app/auth/handlers/agenticAuthorization.ts +1 -1
- package/src/app/auth/handlers/azureBotAuthorization.ts +1 -1
- package/src/app/auth/types.ts +3 -3
- package/src/app/index.ts +8 -0
- package/src/app/streaming/streamingResponse.ts +2 -8
- package/src/app/teamsAttachmentDownloader.ts +11 -1
- package/src/auth/authConfiguration.ts +12 -0
- package/src/auth/index.ts +2 -1
- package/src/auth/jwt-middleware.ts +298 -14
- package/src/auth/msal/msalConnectionSettings.ts +10 -0
- package/src/auth/msal/msalHttpRetryHandlerHelper.ts +161 -0
- package/src/auth/msal/msalTokenProvider.ts +32 -14
- package/src/auth/settings.ts +18 -3
- package/src/cloudAdapter.ts +56 -3
- package/src/errorHelper.ts +155 -114
- package/src/index.ts +1 -0
- package/src/invoke/adaptiveCardInvokeValue.ts +5 -0
- package/src/oauth/userTokenClient.ts +0 -1
- package/src/observability/traces.ts +2 -1
- package/src/outboundHostValidator.ts +172 -0
- package/src/state/agentState.ts +24 -6
|
@@ -8,10 +8,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
8
8
|
};
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.authorizeJWT = void 0;
|
|
11
|
+
exports.getAuthorizedAudience = getAuthorizedAudience;
|
|
11
12
|
exports.clearJwksClients = clearJwksClients;
|
|
12
13
|
exports.buildJwksUri = buildJwksUri;
|
|
13
14
|
exports.getJwksClient = getJwksClient;
|
|
14
|
-
const
|
|
15
|
+
const settings_1 = require("./settings");
|
|
15
16
|
const errorHelper_1 = require("../errorHelper");
|
|
16
17
|
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
17
18
|
const jwks_rsa_1 = __importDefault(require("jwks-rsa"));
|
|
@@ -20,12 +21,241 @@ const agents_telemetry_1 = require("@microsoft/agents-telemetry");
|
|
|
20
21
|
const logger = (0, agents_telemetry_1.debug)('agents:jwt-middleware');
|
|
21
22
|
const jwksClients = new Map();
|
|
22
23
|
const maxJwksClients = 100;
|
|
24
|
+
const authorizedAudience = Symbol('authorizedAudience');
|
|
25
|
+
/**
|
|
26
|
+
* Gets the configured audience selected while authorizing a request.
|
|
27
|
+
* @param req The authorized request.
|
|
28
|
+
* @returns The matched configured client ID, or `undefined` for anonymous requests.
|
|
29
|
+
*/
|
|
30
|
+
function getAuthorizedAudience(req) {
|
|
31
|
+
return req[authorizedAudience];
|
|
32
|
+
}
|
|
23
33
|
/**
|
|
24
34
|
* Clears process-wide JWKS clients.
|
|
25
35
|
*/
|
|
26
36
|
function clearJwksClients() {
|
|
27
37
|
jwksClients.clear();
|
|
28
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Well-known Microsoft first-party token issuer tenant IDs that are always trusted,
|
|
41
|
+
* mirroring the default `ValidIssuers` set in the .NET SDK
|
|
42
|
+
* (Microsoft.Agents.Hosting.AspNetCore `AspNetExtensions.AddAgentAspNetAuthentication`).
|
|
43
|
+
*
|
|
44
|
+
* These identify Microsoft infrastructure tenants used by Azure Bot Service, Teams and
|
|
45
|
+
* skill and SDK-specific Activity callback flows. They are accepted in addition to a connection's configured
|
|
46
|
+
* issuers so that enabling issuer validation does not reject legitimate first-party traffic.
|
|
47
|
+
*/
|
|
48
|
+
const WELL_KNOWN_PUBLIC_TENANT_IDS = [
|
|
49
|
+
'd6d49420-f39b-4df7-a1dc-d59a935871db',
|
|
50
|
+
'f8cdef31-a31e-4b4a-93e4-5f571e91255a',
|
|
51
|
+
'69e9b82d-4842-4902-8d1e-abc5b98a55e8'
|
|
52
|
+
];
|
|
53
|
+
const WELL_KNOWN_GOV_TENANT_ID = 'cab8a31a-1906-4287-a0d8-4eef66b95f6e';
|
|
54
|
+
/**
|
|
55
|
+
* Determines whether the configured authority targets the Azure US Government cloud.
|
|
56
|
+
* @param authority The configured Entra authority.
|
|
57
|
+
* @returns `true` when the authority is a US Government endpoint.
|
|
58
|
+
*/
|
|
59
|
+
function isGovAuthority(authority) {
|
|
60
|
+
return !!authority && /login\.microsoftonline\.us/i.test(authority);
|
|
61
|
+
}
|
|
62
|
+
function getAuthority(authConfig) {
|
|
63
|
+
var _a;
|
|
64
|
+
return (_a = authConfig.authorityEndpoint) !== null && _a !== void 0 ? _a : authConfig.authority;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns the well-known Microsoft first-party issuers that are always trusted for the
|
|
68
|
+
* cloud implied by `authority` (public by default, US Government when the authority is gov).
|
|
69
|
+
* @param authority The configured Entra authority.
|
|
70
|
+
* @returns The well-known first-party issuer list.
|
|
71
|
+
*/
|
|
72
|
+
function getWellKnownFirstPartyIssuers(authority) {
|
|
73
|
+
if (isGovAuthority(authority)) {
|
|
74
|
+
return [
|
|
75
|
+
'https://api.botframework.us',
|
|
76
|
+
`https://sts.windows.net/${WELL_KNOWN_GOV_TENANT_ID}/`,
|
|
77
|
+
`https://login.microsoftonline.us/${WELL_KNOWN_GOV_TENANT_ID}/v2.0`
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
return [
|
|
81
|
+
'https://api.botframework.com',
|
|
82
|
+
...WELL_KNOWN_PUBLIC_TENANT_IDS.flatMap((t) => [
|
|
83
|
+
`https://sts.windows.net/${t}/`,
|
|
84
|
+
`https://login.microsoftonline.com/${t}/v2.0`
|
|
85
|
+
])
|
|
86
|
+
];
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Computes the lowercase issuer allow-list used to validate a token's `iss` claim against a
|
|
90
|
+
* matched connection. The list is the connection's configured issuers (or a tenant-scoped
|
|
91
|
+
* default when none are configured) unioned with the always-trusted Microsoft first-party
|
|
92
|
+
* issuers. Comparison is performed case-insensitively to tolerate operator-provided tenant
|
|
93
|
+
* GUID casing while still rejecting tokens from unrelated tenants.
|
|
94
|
+
* @param authConfig The matched connection configuration.
|
|
95
|
+
* @returns A de-duplicated, lowercased list of accepted issuers.
|
|
96
|
+
*/
|
|
97
|
+
function getValidIssuers(authConfig) {
|
|
98
|
+
var _a;
|
|
99
|
+
const authority = getAuthority(authConfig);
|
|
100
|
+
const configured = authConfig.issuers && authConfig.issuers.length > 0
|
|
101
|
+
? authConfig.issuers
|
|
102
|
+
: (0, settings_1.getDefaultIssuers)((_a = authConfig.tenantId) !== null && _a !== void 0 ? _a : '', authority !== null && authority !== void 0 ? authority : 'https://login.microsoftonline.com');
|
|
103
|
+
const accepted = new Set();
|
|
104
|
+
for (const issuer of [...configured, ...getWellKnownFirstPartyIssuers(authority)]) {
|
|
105
|
+
accepted.add(issuer.toLowerCase());
|
|
106
|
+
}
|
|
107
|
+
return [...accepted];
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Returns the effective tenant identifier for a connection: the tenant embedded in the authority
|
|
111
|
+
* path when present (which takes precedence, matching {@link resolveAuthority}), otherwise the
|
|
112
|
+
* configured `tenantId`.
|
|
113
|
+
* @param authConfig The matched connection configuration.
|
|
114
|
+
* @returns The effective tenant identifier, or `undefined` when none is configured.
|
|
115
|
+
*/
|
|
116
|
+
function getEffectiveTenant(authConfig) {
|
|
117
|
+
const authority = getAuthority(authConfig);
|
|
118
|
+
if (authority) {
|
|
119
|
+
try {
|
|
120
|
+
const segment = new URL(authority.replace(/\/+$/, '')).pathname.split('/').filter(Boolean).pop();
|
|
121
|
+
if (segment) {
|
|
122
|
+
return segment;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch {
|
|
126
|
+
// Non-URL authority — fall through to the configured tenantId.
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
return authConfig.tenantId;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Determines whether a connection is configured as a multi-tenant ("blueprint") agent, i.e. its
|
|
133
|
+
* effective tenant is the Entra `common` or `organizations` meta-tenant. For such agents the
|
|
134
|
+
* calling tenant is not known at configuration time, so the strict issuer allow-list cannot
|
|
135
|
+
* enumerate it and issuer validation must instead accept any canonical Entra issuer for the
|
|
136
|
+
* configured cloud (still bound to the token's `tid` by {@link validateTenantBinding} and anchored
|
|
137
|
+
* by the signature and audience checks).
|
|
138
|
+
* @param authConfig The matched connection configuration.
|
|
139
|
+
* @returns `true` when the connection targets the `common`/`organizations` meta-tenant.
|
|
140
|
+
*/
|
|
141
|
+
function isMultiTenant(authConfig) {
|
|
142
|
+
var _a;
|
|
143
|
+
const tenant = (_a = getEffectiveTenant(authConfig)) === null || _a === void 0 ? void 0 : _a.toLowerCase();
|
|
144
|
+
return tenant === 'common' || tenant === 'organizations';
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Determines whether `iss` is a canonical Entra issuer that may be accepted for a multi-tenant
|
|
148
|
+
* connection. The issuer must carry a concrete tenant GUID and, for cloud-specific v2 issuers,
|
|
149
|
+
* belong to the same cloud as the configured authority (public vs US Government). The cloud-
|
|
150
|
+
* agnostic v1 `sts.windows.net` host is accepted in either cloud.
|
|
151
|
+
* @param iss The token issuer claim.
|
|
152
|
+
* @param authConfig The matched connection configuration.
|
|
153
|
+
* @returns `true` when the issuer is an acceptable Entra tenant issuer for the configured cloud.
|
|
154
|
+
*/
|
|
155
|
+
function isAcceptableTenantIssuer(iss, authConfig) {
|
|
156
|
+
const info = getEntraIssuerInfo(iss);
|
|
157
|
+
if (!info) {
|
|
158
|
+
return false;
|
|
159
|
+
}
|
|
160
|
+
return info.gov === undefined || info.gov === isGovAuthority(getAuthority(authConfig));
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Validates that the token's `iss` claim is present and acceptable for the matched connection.
|
|
164
|
+
* Without this check a signature-valid token from any tenant (Entra signing keys are shared across
|
|
165
|
+
* tenants in a cloud) with a matching audience would be accepted, enabling a cross-tenant
|
|
166
|
+
* authentication bypass for multi-tenant app registrations.
|
|
167
|
+
*
|
|
168
|
+
* For single-tenant connections the issuer must be in the connection's allow-list. For multi-tenant
|
|
169
|
+
* ("blueprint") connections, where the calling tenant is unknown at configuration time, any
|
|
170
|
+
* canonical Entra issuer for the configured cloud is also accepted; the token's tenant is then
|
|
171
|
+
* bound to its `tid` claim by {@link validateTenantBinding} and ultimately anchored by the
|
|
172
|
+
* signature and audience (clientId) checks.
|
|
173
|
+
* @param iss The token issuer claim (from the decoded payload).
|
|
174
|
+
* @param authConfig The matched connection configuration.
|
|
175
|
+
* @throws When the issuer is missing, non-string, or not acceptable for the connection.
|
|
176
|
+
*/
|
|
177
|
+
function validateIssuer(iss, authConfig) {
|
|
178
|
+
if (typeof iss === 'string') {
|
|
179
|
+
if (getValidIssuers(authConfig).includes(iss.toLowerCase())) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
if (isMultiTenant(authConfig) && isAcceptableTenantIssuer(iss, authConfig)) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
const err = agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.JwtIssuerMismatch);
|
|
187
|
+
logger.error(err.message, iss);
|
|
188
|
+
throw err;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Matches a tenant GUID (the format Entra uses for the `tid` claim and the tenant segment of an
|
|
192
|
+
* Entra issuer). Operator-configured issuers may instead use a tenant domain alias, which cannot
|
|
193
|
+
* be compared to the GUID `tid` claim and is therefore left unbound.
|
|
194
|
+
*/
|
|
195
|
+
const ENTRA_TENANT_GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
196
|
+
/**
|
|
197
|
+
* Parses a recognised public or US Government Entra issuer into its tenant GUID and cloud affinity,
|
|
198
|
+
* or returns `undefined` when the issuer is not such an Entra issuer or does not embed a tenant
|
|
199
|
+
* GUID.
|
|
200
|
+
*
|
|
201
|
+
* Only GUID tenants are recognised: the token's `tid` claim is always the tenant GUID, so an issuer
|
|
202
|
+
* whose tenant segment is a domain alias (e.g. `contoso.onmicrosoft.com`) cannot be compared to
|
|
203
|
+
* `tid` and is intentionally left unrecognised to preserve compatibility. Non-Entra issuers such as
|
|
204
|
+
* the Azure Bot Service `api.botframework.*` issuers carry no `tid` claim and are not matched here.
|
|
205
|
+
* @param iss The token issuer claim.
|
|
206
|
+
* @returns The issuer's tenant and cloud affinity, or `undefined` when not a recognised Entra issuer.
|
|
207
|
+
*/
|
|
208
|
+
function getEntraIssuerInfo(iss) {
|
|
209
|
+
const v1 = /^https:\/\/sts\.windows\.net\/([^/]+)\/$/i.exec(iss);
|
|
210
|
+
if (v1) {
|
|
211
|
+
return ENTRA_TENANT_GUID.test(v1[1]) ? { tenant: v1[1].toLowerCase() } : undefined;
|
|
212
|
+
}
|
|
213
|
+
const v2 = /^([^:]+):\/\/([^/]+)\/([^/]+)\/v2\.0$/.exec(iss);
|
|
214
|
+
const v2Host = v2 ? /^login\.microsoftonline\.(com|us)$/i.exec(v2[2]) : undefined;
|
|
215
|
+
if (v2 && v2Host && v2[1].toLowerCase() === 'https' && ENTRA_TENANT_GUID.test(v2[3])) {
|
|
216
|
+
return { tenant: v2[3].toLowerCase(), gov: v2Host[1].toLowerCase() === 'us' };
|
|
217
|
+
}
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Extracts the tenant GUID embedded in a recognised public or US Government Entra issuer, or
|
|
222
|
+
* `undefined` when the issuer is not such an Entra issuer or does not embed a tenant GUID.
|
|
223
|
+
* @param iss The token issuer claim.
|
|
224
|
+
* @returns The lowercased tenant GUID, or `undefined` when no bindable tenant is present.
|
|
225
|
+
*/
|
|
226
|
+
function getIssuerTenant(iss) {
|
|
227
|
+
var _a;
|
|
228
|
+
return (_a = getEntraIssuerInfo(iss)) === null || _a === void 0 ? void 0 : _a.tenant;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Validates that an Entra token's `tid` (tenant id) claim matches the tenant GUID embedded in its
|
|
232
|
+
* `iss` claim. This binds the accepted issuer to the token's tenant. Because
|
|
233
|
+
* Entra signing keys are shared across tenants within a cloud, requiring the issuer's tenant and
|
|
234
|
+
* the `tid` claim to agree prevents a token whose `iss` was allow-listed (for example one of the
|
|
235
|
+
* always-trusted Microsoft first-party tenants) from being accepted on behalf of a different
|
|
236
|
+
* tenant.
|
|
237
|
+
*
|
|
238
|
+
* The binding only applies when both claims are strings and the issuer is a recognised Entra
|
|
239
|
+
* issuer carrying a GUID tenant. Missing/non-string claims, Azure Bot Service issuers, and
|
|
240
|
+
* alias-based issuers are skipped for backward compatibility.
|
|
241
|
+
* @param iss The token issuer claim.
|
|
242
|
+
* @param tid The token tenant id claim.
|
|
243
|
+
* @throws When both claims are strings and the issuer embeds a tenant GUID different from `tid`.
|
|
244
|
+
*/
|
|
245
|
+
function validateTenantBinding(iss, tid) {
|
|
246
|
+
if (typeof iss !== 'string' || typeof tid !== 'string') {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const issuerTenant = getIssuerTenant(iss);
|
|
250
|
+
if (!issuerTenant) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (tid.toLowerCase() !== issuerTenant) {
|
|
254
|
+
const err = agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.JwtTenantMismatch);
|
|
255
|
+
logger.error(err.message, tid);
|
|
256
|
+
throw err;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
29
259
|
/**
|
|
30
260
|
* Builds the JWKS URI for the given token issuer and auth configuration.
|
|
31
261
|
* @param iss The token issuer claim.
|
|
@@ -34,9 +264,14 @@ function clearJwksClients() {
|
|
|
34
264
|
*/
|
|
35
265
|
function buildJwksUri(iss, authConfig) {
|
|
36
266
|
var _a;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
267
|
+
switch (typeof iss === 'string' ? iss.toLowerCase() : '') {
|
|
268
|
+
case 'https://api.botframework.com':
|
|
269
|
+
return 'https://login.botframework.com/v1/.well-known/keys';
|
|
270
|
+
case 'https://api.botframework.us':
|
|
271
|
+
return 'https://login.botframework.azure.us/v1/.well-known/keys';
|
|
272
|
+
default:
|
|
273
|
+
return `${(0, settings_1.resolveAuthority)((_a = authConfig.authorityEndpoint) !== null && _a !== void 0 ? _a : authConfig.authority, authConfig.tenantId)}/discovery/v2.0/keys`;
|
|
274
|
+
}
|
|
40
275
|
}
|
|
41
276
|
function getJwksClient(jwksUri) {
|
|
42
277
|
// Check if a client for this JWKS URI already exists in the cache.
|
|
@@ -62,7 +297,7 @@ function getJwksClient(jwksUri) {
|
|
|
62
297
|
* Verifies the JWT token.
|
|
63
298
|
* @param raw The raw JWT token.
|
|
64
299
|
* @param config The authentication configuration.
|
|
65
|
-
* @returns A promise that resolves to the
|
|
300
|
+
* @returns A promise that resolves to the verified payload and matched configured audience.
|
|
66
301
|
*/
|
|
67
302
|
const verifyToken = async (raw, config) => {
|
|
68
303
|
const payload = jsonwebtoken_1.default.decode(raw);
|
|
@@ -70,18 +305,23 @@ const verifyToken = async (raw, config) => {
|
|
|
70
305
|
if (!payload) {
|
|
71
306
|
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.InvalidJwtToken);
|
|
72
307
|
}
|
|
73
|
-
const
|
|
308
|
+
const audiences = Array.isArray(payload.aud)
|
|
309
|
+
? payload.aud
|
|
310
|
+
: typeof payload.aud === 'string'
|
|
311
|
+
? [payload.aud]
|
|
312
|
+
: [];
|
|
74
313
|
const matchingEntry = config.connections && config.connections.size > 0
|
|
75
|
-
? [...config.connections.entries()].find(([_, configuration]) => configuration.clientId ===
|
|
314
|
+
? [...config.connections.entries()].find(([_, configuration]) => typeof configuration.clientId === 'string' && audiences.includes(configuration.clientId))
|
|
76
315
|
: undefined;
|
|
77
316
|
if (!matchingEntry) {
|
|
78
317
|
const err = agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.JwtAudienceMismatch);
|
|
79
|
-
logger.error(err.message,
|
|
318
|
+
logger.error(err.message, audiences);
|
|
80
319
|
throw err;
|
|
81
320
|
}
|
|
82
321
|
const [key, authConfig] = matchingEntry;
|
|
83
322
|
logger.debug(`Audience found at key: ${key}`);
|
|
84
|
-
const
|
|
323
|
+
const issuer = typeof payload.iss === 'string' ? payload.iss : '';
|
|
324
|
+
const jwksUri = buildJwksUri(issuer, authConfig);
|
|
85
325
|
logger.debug(`fetching keys from ${jwksUri}`);
|
|
86
326
|
const jwksClient = getJwksClient(jwksUri);
|
|
87
327
|
const getKey = (header, callback) => {
|
|
@@ -103,7 +343,7 @@ const verifyToken = async (raw, config) => {
|
|
|
103
343
|
algorithms: ['RS256'],
|
|
104
344
|
clockTolerance: 300
|
|
105
345
|
};
|
|
106
|
-
|
|
346
|
+
const verifiedPayload = await new Promise((resolve, reject) => {
|
|
107
347
|
jsonwebtoken_1.default.verify(raw, getKey, verifyOptions, (err, user) => {
|
|
108
348
|
if (err) {
|
|
109
349
|
logger.error('jwt.verify ', JSON.stringify(err));
|
|
@@ -113,6 +353,14 @@ const verifyToken = async (raw, config) => {
|
|
|
113
353
|
resolve(user);
|
|
114
354
|
});
|
|
115
355
|
});
|
|
356
|
+
if (authConfig.validateIssuer) {
|
|
357
|
+
validateIssuer(verifiedPayload.iss, authConfig);
|
|
358
|
+
}
|
|
359
|
+
validateTenantBinding(verifiedPayload.iss, verifiedPayload.tid);
|
|
360
|
+
return {
|
|
361
|
+
payload: verifiedPayload,
|
|
362
|
+
audience: authConfig.clientId
|
|
363
|
+
};
|
|
116
364
|
};
|
|
117
365
|
/**
|
|
118
366
|
* Determines whether an `Authorization` header value is present (non-empty).
|
|
@@ -195,9 +443,11 @@ const authorizeJWT = (authConfig) => {
|
|
|
195
443
|
const token = extractBearerToken(req.headers.authorization);
|
|
196
444
|
if (token) {
|
|
197
445
|
try {
|
|
198
|
-
const
|
|
199
|
-
logger.debug('token verified for ',
|
|
200
|
-
req.user =
|
|
446
|
+
const verifiedToken = await verifyToken(token, authConfig);
|
|
447
|
+
logger.debug('token verified for ', verifiedToken.payload);
|
|
448
|
+
req.user = verifiedToken.payload;
|
|
449
|
+
const authorizedRequest = req;
|
|
450
|
+
authorizedRequest[authorizedAudience] = verifiedToken.audience;
|
|
201
451
|
}
|
|
202
452
|
catch (err) {
|
|
203
453
|
failed = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jwt-middleware.js","sourceRoot":"","sources":["../../../src/auth/jwt-middleware.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAkBH,4CAEC;AAQD,oCAIC;AAED,sCAkBC;AAlDD,2DAAyE;AAGzE,gDAAuC;AACvC,gEAA4D;AAC5D,wDAA0D;AAC1D,gEAA6F;AAC7F,kEAAmD;AAEnD,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,uBAAuB,CAAC,CAAA;AAC7C,MAAM,WAAW,GAAG,IAAI,GAAG,EAAsB,CAAA;AACjD,MAAM,cAAc,GAAG,GAAG,CAAA;AAE1B;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,WAAW,CAAC,KAAK,EAAE,CAAA;AACrB,CAAC;AAED;;;;;GAKG;AACH,SAAgB,YAAY,CAAE,GAAW,EAAE,UAA6B;;IACtE,OAAO,GAAG,KAAK,8BAA8B;QAC3C,CAAC,CAAC,oDAAoD;QACtD,CAAC,CAAC,GAAG,IAAA,oCAAgB,EAAC,MAAA,UAAU,CAAC,iBAAiB,mCAAI,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,QAAQ,CAAC,sBAAsB,CAAA;AAC1H,CAAC;AAED,SAAgB,aAAa,CAAE,OAAe;IAC5C,mEAAmE;IACnE,IAAI,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;IACrC,IAAI,CAAC,MAAM,EA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MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;oBACnC,GAAG,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,CAAA;gBAClC,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,IAAI,CAAA;oBACb,MAAM,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAA;oBAC9C,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,gCAAgC,EAAE,CAAC,CAAA;gBAC9E,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,IAAI,EAAE,CAAA;QACR,CAAC;IACH,CAAC,CAAA;AACH,CAAC,CAAA;AAlDY,QAAA,YAAY,gBAkDxB"}
|
|
@@ -65,4 +65,12 @@ export interface MsalConnectionSettings extends ConnectionSettingsBase {
|
|
|
65
65
|
* The federated client ID for the authentication configuration, used for workload identity federation scenarios.
|
|
66
66
|
*/
|
|
67
67
|
federatedClientId?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Maximum number of retries for an MSAL HTTP request that returns status 408.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* The initial request is not included in this count. Set to `0` to disable retries.
|
|
73
|
+
* Defaults to `2`.
|
|
74
|
+
*/
|
|
75
|
+
msalRetryCount?: number;
|
|
68
76
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*/
|
|
5
|
+
import { INetworkModule, NetworkRequestOptions, NetworkResponse } from '@azure/msal-node';
|
|
6
|
+
/**
|
|
7
|
+
* The default number of retries made for an MSAL HTTP request.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_MSAL_RETRY_COUNT = 2;
|
|
10
|
+
/**
|
|
11
|
+
* Converts a configured MSAL retry count to its effective runtime value.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeMsalRetryCount(retryCount: number | undefined): number;
|
|
14
|
+
/**
|
|
15
|
+
* MSAL network client that retries responses with HTTP status 408 (Request Timeout).
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* `maxRetryCount` is the number of retries after the initial request. Responses with
|
|
19
|
+
* any other status are returned immediately and retries have no additional delay.
|
|
20
|
+
*/
|
|
21
|
+
export declare class MsalHttpRetryHandlerHelper implements INetworkModule {
|
|
22
|
+
private readonly networkClient;
|
|
23
|
+
private readonly maxRetryCount;
|
|
24
|
+
constructor(networkClient?: INetworkModule, maxRetryCount?: number);
|
|
25
|
+
/**
|
|
26
|
+
* Sends an HTTP GET request, retrying only Request Timeout responses.
|
|
27
|
+
*/
|
|
28
|
+
sendGetRequestAsync<T>(url: string, options?: NetworkRequestOptions, timeout?: number): Promise<NetworkResponse<T>>;
|
|
29
|
+
/**
|
|
30
|
+
* Sends an HTTP POST request, retrying only Request Timeout responses.
|
|
31
|
+
*/
|
|
32
|
+
sendPostRequestAsync<T>(url: string, options?: NetworkRequestOptions): Promise<NetworkResponse<T>>;
|
|
33
|
+
private sendWithRetries;
|
|
34
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
* Licensed under the MIT License.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MsalHttpRetryHandlerHelper = exports.DEFAULT_MSAL_RETRY_COUNT = void 0;
|
|
8
|
+
exports.normalizeMsalRetryCount = normalizeMsalRetryCount;
|
|
9
|
+
const agents_activity_1 = require("@microsoft/agents-activity");
|
|
10
|
+
const agents_telemetry_1 = require("@microsoft/agents-telemetry");
|
|
11
|
+
const errorHelper_1 = require("../../errorHelper");
|
|
12
|
+
const logger = (0, agents_telemetry_1.debug)('agents:msal');
|
|
13
|
+
const requestTimeoutStatus = 408;
|
|
14
|
+
/**
|
|
15
|
+
* The default number of retries made for an MSAL HTTP request.
|
|
16
|
+
*/
|
|
17
|
+
exports.DEFAULT_MSAL_RETRY_COUNT = 2;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a configured MSAL retry count to its effective runtime value.
|
|
20
|
+
*/
|
|
21
|
+
function normalizeMsalRetryCount(retryCount) {
|
|
22
|
+
if (!Number.isFinite(retryCount)) {
|
|
23
|
+
return exports.DEFAULT_MSAL_RETRY_COUNT;
|
|
24
|
+
}
|
|
25
|
+
return Math.max(0, Math.floor(retryCount));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* MSAL network client that retries responses with HTTP status 408 (Request Timeout).
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* `maxRetryCount` is the number of retries after the initial request. Responses with
|
|
32
|
+
* any other status are returned immediately and retries have no additional delay.
|
|
33
|
+
*/
|
|
34
|
+
class MsalHttpRetryHandlerHelper {
|
|
35
|
+
constructor(networkClient = new MsalHttpClient(), maxRetryCount = exports.DEFAULT_MSAL_RETRY_COUNT) {
|
|
36
|
+
this.networkClient = networkClient;
|
|
37
|
+
this.maxRetryCount = normalizeMsalRetryCount(maxRetryCount);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Sends an HTTP GET request, retrying only Request Timeout responses.
|
|
41
|
+
*/
|
|
42
|
+
async sendGetRequestAsync(url, options, timeout) {
|
|
43
|
+
return this.sendWithRetries(() => this.networkClient.sendGetRequestAsync(url, options, timeout));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sends an HTTP POST request, retrying only Request Timeout responses.
|
|
47
|
+
*/
|
|
48
|
+
async sendPostRequestAsync(url, options) {
|
|
49
|
+
return this.sendWithRetries(() => this.networkClient.sendPostRequestAsync(url, options));
|
|
50
|
+
}
|
|
51
|
+
async sendWithRetries(send) {
|
|
52
|
+
let response = await send();
|
|
53
|
+
let attempt;
|
|
54
|
+
for (attempt = 0; response.status === requestTimeoutStatus && attempt < this.maxRetryCount; attempt++) {
|
|
55
|
+
logger.debug('MSAL retry on request timeout (retry %d/%d)', attempt + 1, this.maxRetryCount);
|
|
56
|
+
response = await send();
|
|
57
|
+
}
|
|
58
|
+
logger.debug('MSAL request completed with status %d after %d attempt(s)', response.status, attempt + 1);
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.MsalHttpRetryHandlerHelper = MsalHttpRetryHandlerHelper;
|
|
63
|
+
/**
|
|
64
|
+
* Default MSAL-compatible network implementation. MSAL Node does not export its
|
|
65
|
+
* built-in HTTP client, so the retry handler uses the same native fetch contract.
|
|
66
|
+
*/
|
|
67
|
+
class MsalHttpClient {
|
|
68
|
+
async sendGetRequestAsync(url, options, timeout) {
|
|
69
|
+
return this.sendRequest(url, 'GET', options, timeout);
|
|
70
|
+
}
|
|
71
|
+
async sendPostRequestAsync(url, options) {
|
|
72
|
+
return this.sendRequest(url, 'POST', options);
|
|
73
|
+
}
|
|
74
|
+
async sendRequest(url, method, options, timeout) {
|
|
75
|
+
var _a;
|
|
76
|
+
const controller = new AbortController();
|
|
77
|
+
const timeoutId = timeout
|
|
78
|
+
? setTimeout(() => controller.abort(), timeout)
|
|
79
|
+
: undefined;
|
|
80
|
+
let response;
|
|
81
|
+
try {
|
|
82
|
+
response = await fetch(url, {
|
|
83
|
+
method,
|
|
84
|
+
headers: options === null || options === void 0 ? void 0 : options.headers,
|
|
85
|
+
body: method === 'POST' ? options === null || options === void 0 ? void 0 : options.body : undefined,
|
|
86
|
+
signal: controller.signal
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
const innerException = error instanceof Error ? error : undefined;
|
|
91
|
+
if ((innerException === null || innerException === void 0 ? void 0 : innerException.name) === 'AbortError') {
|
|
92
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.TokenRequestTimeout, innerException, { timeoutMs: String(timeout) });
|
|
93
|
+
}
|
|
94
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.MsalHttpRequestFailed, innerException, {
|
|
95
|
+
message: (_a = innerException === null || innerException === void 0 ? void 0 : innerException.message) !== null && _a !== void 0 ? _a : 'unknown'
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
if (timeoutId) {
|
|
100
|
+
clearTimeout(timeoutId);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const headers = {};
|
|
104
|
+
response.headers.forEach((value, key) => {
|
|
105
|
+
headers[key] = value;
|
|
106
|
+
});
|
|
107
|
+
return {
|
|
108
|
+
headers,
|
|
109
|
+
body: await this.parseBody(response),
|
|
110
|
+
status: response.status
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
async parseBody(response) {
|
|
114
|
+
const text = await response.text();
|
|
115
|
+
try {
|
|
116
|
+
return JSON.parse(text);
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
if (response.status === requestTimeoutStatus) {
|
|
120
|
+
return {};
|
|
121
|
+
}
|
|
122
|
+
throw agents_activity_1.ExceptionHelper.generateException(Error, errorHelper_1.Errors.MsalResponseUnparsable, error instanceof Error ? error : undefined);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=msalHttpRetryHandlerHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msalHttpRetryHandlerHelper.js","sourceRoot":"","sources":["../../../../src/auth/msal/msalHttpRetryHandlerHelper.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAkBH,0DAMC;AArBD,gEAA4D;AAC5D,kEAAmD;AACnD,mDAA0C;AAE1C,MAAM,MAAM,GAAG,IAAA,wBAAK,EAAC,aAAa,CAAC,CAAA;AACnC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAEhC;;GAEG;AACU,QAAA,wBA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C;YACf,IAAI,QAAQ,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;gBAC7C,OAAO,EAAO,CAAA;YAChB,CAAC;YACD,MAAM,iCAAe,CAAC,iBAAiB,CACrC,KAAK,EACL,oBAAM,CAAC,sBAAsB,EAC7B,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAC3C,CAAA;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -69,6 +69,7 @@ export declare class MsalTokenProvider implements AuthProvider {
|
|
|
69
69
|
getAgenticUserToken(tenantId: string, agentAppInstanceId: string, agenticUserId: string, scopes: string[]): Promise<string>;
|
|
70
70
|
getAgenticApplicationToken(tenantId: string, agentAppInstanceId: string): Promise<string>;
|
|
71
71
|
private readonly sysOptions;
|
|
72
|
+
private getSystemOptions;
|
|
72
73
|
/**
|
|
73
74
|
* Generates the client assertion using the provided certificate.
|
|
74
75
|
* @param authConfig The authentication configuration.
|