azure-sites-backend permission as optional

Signed-off-by: Deepankumar Loganathan <deepan0433@gmail.com>
This commit is contained in:
Deepankumar Loganathan
2023-11-13 23:10:54 +01:00
committed by blam
parent 9f9063c990
commit c709fcb5e4
2 changed files with 24 additions and 20 deletions
+1 -1
View File
@@ -62,7 +62,7 @@ export interface RouterOptions {
// (undocumented)
logger: Logger;
// (undocumented)
permissions: PermissionEvaluator;
permissions?: PermissionEvaluator;
}
// (No @packageDocumentation comment for this package)
@@ -39,7 +39,7 @@ export interface RouterOptions {
logger: Logger;
azureSitesApi: AzureSitesApi;
catalogApi: CatalogApi;
permissions: PermissionEvaluator;
permissions?: PermissionEvaluator;
}
/** @public */
@@ -84,15 +84,17 @@ export async function createRouter(
throw new NotAllowedError();
}
const decision = (
await permissions.authorize(
[{ permission: azureSitesActionPermission, resourceRef }],
{
token,
},
)
)[0];
if (decision.result === AuthorizeResult.DENY) {
const decision = permissions
? (
await permissions.authorize(
[{ permission: azureSitesActionPermission, resourceRef }],
{
token,
},
)
)[0]
: undefined;
if (decision && decision.result === AuthorizeResult.DENY) {
throw new NotAllowedError('Unauthorized');
}
@@ -133,15 +135,17 @@ export async function createRouter(
throw new NotAllowedError();
}
const decision = (
await permissions.authorize(
[{ permission: azureSitesActionPermission, resourceRef }],
{
token,
},
)
)[0];
if (decision.result === AuthorizeResult.DENY) {
const decision = permissions
? (
await permissions.authorize(
[{ permission: azureSitesActionPermission, resourceRef }],
{
token,
},
)
)[0]
: undefined;
if (decision && decision.result === AuthorizeResult.DENY) {
throw new NotAllowedError('Unauthorized');
}