Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable specific endpoint from protectedResources on MSAL Angular

im working with MSALv2 on Angular 8, and I need disable the authentication for specific endpoints that dont need, is this possible? Here is my config:

export function MSALInterceptorConfigFactory(): MsalInterceptorConfiguration {
  const protectedResourceMap = new Map<string, Array<string>>();
  protectedResourceMap.set('https://graph.microsoft.com/v1.0/me', ['user.read']);
  protectedResourceMap.set(`${environment.API_URL}`, ['api://f70731a6-6df1-4762-b267-54ea9741a7a2/User.read']);

And I need disable the auth only for ${environment.API_URL}` / x-resource Thank you!

like image 581
Jose Miguel Chacón Avatar asked Jan 19 '26 21:01

Jose Miguel Chacón


1 Answers

Yes, in protected resource map, set the scope to null for that particular endpoint, and make sure that it is placed before any other wildcard endpoints which may match.

For example, if ${environment.API_URL}is all protected, except for the endpoint ${environment.API_URL}/signup then your protectedResourceMap would look something like:

const protectedResourceMap = new Map<string, Array<string> | null>();
protectedResourceMap.set(`${environment.API_URL}/signup`, null);
protectedResourceMap.set(`${environment.API_URL`, environment.API_SCOPES);
like image 102
MSwehli Avatar answered Jan 21 '26 11:01

MSwehli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!