This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { BrowserModule } from '@angular/platform-browser'; | |
import { NgModule } from '@angular/core'; | |
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http'; | |
import { MsalModule, MsalInterceptor } from '@azure/msal-angular'; | |
import { AppRoutingModule } from './app-routing.module'; | |
import { AppComponent } from './app.component'; | |
export const protectedResourceMap: [string, string[]][] = [ | |
['https://graph.microsoft.com/v1.0/me', ['user.read']] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { Routes, RouterModule } from '@angular/router'; | |
import { MsalGuard } from '@azure/msal-angular'; | |
import { HomeComponent } from './home/home.component'; | |
const routes: Routes = [ | |
{ | |
path: '', | |
canActivate: [ | |
MsalGuard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { AuthService } from './auth.service'; | |
@Component({ | |
selector: 'app-root', | |
templateUrl: './app.component.html', | |
styleUrls: ['./app.component.css'] | |
}) | |
export class AppComponent implements OnInit { | |
title = 'SecureApp'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<router-outlet></router-outlet> | |
<button class="dropdown-item" (click)="logOut()">Logout</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { BroadcastService, MsalService } from '@azure/msal-angular'; | |
import { Logger, CryptoUtils } from 'msal'; | |
@Injectable() | |
export class AuthService { | |
isIframe = false; | |
loggedIn = false; | |
constructor( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
public void ConfigureServices(IServiceCollection services) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AzureAd": { | |
"Instance": "https://login.microsoftonline.com/", | |
/******************************************************* | |
Tenant ID identifying Azure AD instance | |
Enter 'common', or 'organizations' or the Tenant Id | |
Obtained from the Azure portal. Select 'Endpoints' | |
from the 'App registrations' blade | |
*******************************************************/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@if (User.Identity.IsAuthenticated) | |
{ | |
<li class="nav-item"> | |
<span class="navbar-text text-dark">Hello @User.Identity.Name!</span> | |
</li> | |
<li class="nav-item"> | |
<a class="nav-link text-dark" asp-area="MicrosoftIdentity" | |
asp-controller="Account" asp-action="SignOut"> | |
Sign out | |
</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
public void ConfigureServices(IServiceCollection services) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AzureAd": { | |
"Instance": "https://login.microsoftonline.com/", | |
"TenantId": "da41245a5-11b3-996c-00a8-4d99re19f292", | |
"ClientId": "5a886671-26ae-4844-84d8-19cb3e1cfbb5", | |
"CallbackPath": "/signin-oidc", | |
"SignedOutCallbackPath ": "/signout-callback-oidc" | |
}, | |
"Logging": { | |
"LogLevel": { |
OlderNewer