Allow extending MsalGuard
Core Library
@azure/msal-browser
Wrapper Library
@azure/msal-angular
Description
The MsalGuard works great for basic usecases, but sometimes you just need a small change. At the moment you'll need to copy all the code from the MsalGuard into a new Guard. It would be great if the activateHelper would be marked as protected. (And also marking all the properties in the constructor as protected)
That would allow to create an extended MsalGuard really easily:
import { RouterStateSnapshot, UrlTree } from "@angular/router";
import { Observable } from "rxjs";
import { MsalGuard } from "./msal.guard";
export class RoleMsalGuard extends MsalGuard {
activateHelper(state?: RouterStateSnapshot): Observable<boolean|UrlTree> {
let result = super.activateHelper(state);
// Do something here with the result
return result;
}
}
Source
External (Customer)
@svrooij Thanks for filing, we'll take this into consideration.
Class and InjectionToken guards and resolvers, such as the current MsalGuard implementation, are scheduled for removal in Angular 17. I would not recommend extending (or allowing users to extend) MsalGuard as it will introduce additional complications when it is removed in order to support newer Angular versions.