
Security News
Browserslist-rs Gets Major Refactor, Cutting Binary Size by Over 1MB
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
angular-msal
Advanced tools
This package is created when @azure/msal wasn't ready to use. Because there are so many configuration options, this packages tries to make things easier. See the demo project for a working example using login-redirect and login-popup.
npm install angular-msal --save
This is how I use the package: I have a userService that has a function: TryToGetUser, which tries to get the current user from my backend (using the tokens ObjectId which I make sure is equal to my User.Id)
Add the MsalModule and HttpIntercepter in app.module.ts
@NgModule({
imports: [
MsalModule.forRoot({
clientId: environment.clientId,
authority: environment.authority + environment.userflow,
consentScopes: environment.scopes,
lang: 'en-US',
level: environment.production ? LogLevel.Error : LogLevel.Info
}),
}),
],
providers: [UserService,
{ provide: HTTP_INTERCEPTORS, useClass: MsalInterceptor, multi: true }
]
@Injectable()
export class UserService {
cachedUser: User;
constructor(private authService: MsalService, private http: HttpClient) {
}
public tryToGetUser() {
if (this.authService.getAccount()) {
return this.getUser();
}
return of(null);
}
public getUser() {
return this.http.get<User>(`User/loggedinuser`).pipe(tap(user => {
this.cachedUser = user;
}));
}
}
login.component.ts
export class LoginPageComponent {
constructor(private authService: MsalService, public userService: UserService, private router: Router) {
loginRedirect = () => this.authService.loginRedirect();
loginPopup = () => {
const response = await this.msalService.loginPopup();
if (response.idToken) {
this.router.navigate(['/my-profile']);
}
}
To logout use
this.msalService.logout();
FAQs
msal in Angular as simple as possible
The npm package angular-msal receives a total of 3 weekly downloads. As such, angular-msal popularity was classified as not popular.
We found that angular-msal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.
Security News
The official Go SDK for the Model Context Protocol is in development, with a stable, production-ready release expected by August 2025.