Skip to content

Commit

Permalink
Merge branch 'dev8'
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Nov 28, 2023
2 parents ec45dc9 + a638c19 commit 9308d07
Show file tree
Hide file tree
Showing 86 changed files with 1,439 additions and 1,439 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
with:
dotnet-version: '8.0'
include-prerelease: True
- name: Build AngularAzureADMultipleApis
run: dotnet build ./AngularAzureADMultipleApis/ApiWithMutlipleApis.sln
- name: Build AngularMicrsoftEntraIDMultipleApis
run: dotnet build ./AngularMicrsoftEntraIDMultipleApis/ApiWithMutlipleApis.sln
- name: Build BlazorWithApis
run: dotnet build ./BlazorWithApis/BlazorApis.sln
- name: Build ConfidentialClientCredentialsCertificate
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-----BEGIN RSA PRIVATE KEY-----
MIICXQIBAAKBgQCs7HI0KWqXEjH1fxXdkgVHg+1UgbtBhwkeZ3WhBsTGcwlqGUmzqlhKiR2hTd9G
dMhQm1tFeU9qAMpmglxR+XgoZoEv9uoXw/TeegdKvn1V3exTxeULIDGJOXK6wQ1M+4FLMr7zBWlM
hWmqcbYTHHVwwYd+ycDRHU3NAIxDfMUSQQIDAQABAoGAIB8z/7iJ0lJQ8XeQCj6ruGMrXP1UWZHK
AdnaIfVt7CdGYm0cIcHM8NuTo3khtqbO5xpU1Az60YggEPa6S4f558kGBIg4PQVxgE/Kv77ptGAk
rZG9FaCyIibGMh5aJLtxG0Fh1FGnuK1Xk1BKXtaGRUkZpKGg4rMJ9w3qp/T5vLkCQQDe+FiMqY2s
pxHEz+h3NJ0H2T81FCx2upf1fjTVtlQnJ7Gds6eZT0zwa3z1bSw+VkxICERY8C43bzPUJUgPIyLX
AkEAxooyVkJHmxlcIvZfrZPvQs+2GOXpWVnyjNUWf8t9G2MsmkdGIkp7oJhi5obpdNR+3jQe0xyr
Dvy1h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xFV+/YweK+6smN2v+dYZAi
5KShWRl5fwpl+mdJT3aziRb/kfYkhGPQMO06OnGzjNKt7Rg0Z8mD
-----END RSA PRIVATE KEY-----
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
-----BEGIN CERTIFICATE-----
MIICQDCCAamgAwIBAgIJAIKGapdMCt4NMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNVBAMTCWxvY2Fs
aG9zdDAeFw0yMDAyMjAyMjU3MjFaFw0zMDAyMjEyMjU3MjFaMBQxEjAQBgNVBAMTCWxvY2FsaG9z
dDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEArOxyNClqlxIx9X8V3ZIFR4PtVIG7QYcJHmd1
oQbExnMJahlJs6pYSokdoU3fRnTIUJtbRXlPagDKZoJcUfl4KGaBL/bqF8P03noHSr59Vd3sU8Xl
CyAxiTlyusENTPuBSzK+8wVpTIVpqnG2Exx1cMGHfsnA0R1NzQCMQ3zFEkECAwEAAaOBmTCBljAS
BgNVHRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIB/jAUBgNVHREEDTALgglsb2NhbGhvc3Qw
OwYDVR0lBDQwMgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDAwYIKwYBBQUHAwQGCCsGAQUF
BwMIMB0GA1UdDgQWBBQaVighscgq5k8BjEzeSsZp+6RxITANBgkqhkiG9w0BAQsFAAOBgQBXH/Sq
jekwz+O0eG0zA2MA2LSwt7OELi54vATFYkXO45IO5frRagUTWDkx85/Vfm9OcdfoaHD1UzPkGBU0
BPsnN3SGCB3Pk5jSRaXIBBiqByDFiP+G6EYmUYhLxB3FpJp6S5KlnQtdtLkl3KuT8KBtc9haro+e
lDlUx5s/FM3SJw==
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIICQDCCAamgAwIBAgIJAIKGapdMCt4NMA0GCSqGSIb3DQEBCwUAMBQxEjAQBgNVBAMTCWxvY2Fs
aG9zdDAeFw0yMDAyMjAyMjU3MjFaFw0zMDAyMjEyMjU3MjFaMBQxEjAQBgNVBAMTCWxvY2FsaG9z
dDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEArOxyNClqlxIx9X8V3ZIFR4PtVIG7QYcJHmd1
oQbExnMJahlJs6pYSokdoU3fRnTIUJtbRXlPagDKZoJcUfl4KGaBL/bqF8P03noHSr59Vd3sU8Xl
CyAxiTlyusENTPuBSzK+8wVpTIVpqnG2Exx1cMGHfsnA0R1NzQCMQ3zFEkECAwEAAaOBmTCBljAS
BgNVHRMBAf8ECDAGAQH/AgEDMA4GA1UdDwEB/wQEAwIB/jAUBgNVHREEDTALgglsb2NhbGhvc3Qw
OwYDVR0lBDQwMgYIKwYBBQUHAwEGCCsGAQUFBwMCBggrBgEFBQcDAwYIKwYBBQUHAwQGCCsGAQUF
BwMIMB0GA1UdDgQWBBQaVighscgq5k8BjEzeSsZp+6RxITANBgkqhkiG9w0BAQsFAAOBgQBXH/Sq
jekwz+O0eG0zA2MA2LSwt7OELi54vATFYkXO45IO5frRagUTWDkx85/Vfm9OcdfoaHD1UzPkGBU0
BPsnN3SGCB3Pk5jSRaXIBBiqByDFiP+G6EYmUYhLxB3FpJp6S5KlnQtdtLkl3KuT8KBtc9haro+e
lDlUx5s/FM3SJw==
-----END CERTIFICATE-----
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Component, OnInit } from '@angular/core';
import { AuthService } from './auth.service';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
})
export class AppComponent implements OnInit {
constructor(public authService: AuthService) {}

ngOnInit() {
this.authService
.checkAuth()
.subscribe((isAuthenticated) =>
console.log('app authenticated', isAuthenticated)
);
}
}
import { Component, OnInit } from '@angular/core';
import { AuthService } from './auth.service';

@Component({
selector: 'app-root',
templateUrl: 'app.component.html',
})
export class AppComponent implements OnInit {
constructor(public authService: AuthService) {}

ngOnInit() {
this.authService
.checkAuth()
.subscribe((isAuthenticated) =>
console.log('app authenticated', isAuthenticated)
);
}
}
Original file line number Diff line number Diff line change
@@ -1,67 +1,67 @@
import { DirectApiCallComponent } from './directApiCall/directApiCall.component';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { AuthModule, OidcConfigService, LogLevel } from 'angular-auth-oidc-client';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthInterceptor } from './auth.interceptor';
import { NavMenuComponent } from './nav-menu/nav-menu.component';
import { GraphApiCallComponent } from './graphApiCall/graphApiCall.component';
import { ApplicationApiCallComponent } from './applicationApiCall/applicationApiCall.component';
import { DelegatedApiCallComponent } from './delegatedApiCall/delegatedApiCall.component';
import { AuthorizationGuard } from './authorization.guard';

@NgModule({
declarations: [
AppComponent,
HomeComponent,
NavMenuComponent,
UnauthorizedComponent,
DirectApiCallComponent,
GraphApiCallComponent,
ApplicationApiCallComponent,
DelegatedApiCallComponent
],
imports: [
BrowserModule,
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'directApiCall', component: DirectApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'graphApiCall', component: GraphApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'applicationApiCall', component: ApplicationApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'delegatedApiCall', component: DelegatedApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'unauthorized', component: UnauthorizedComponent },
], { relativeLinkResolution: 'legacy' }),
AuthModule.forRoot({
config: {
authority: 'https://login.microsoftonline.com/7ff95b15-dc21-4ba6-bc92-824856578fc1/v2.0',
authWellknownEndpointUrl: 'https://login.microsoftonline.com/7ff95b15-dc21-4ba6-bc92-824856578fc1/v2.0',
redirectUrl: window.location.origin,
clientId: 'ad6b0351-92b4-4ee9-ac8d-3e76e5fd1c67',
scope: 'openid profile email api://2b50a014-f353-4c10-aace-024f19a55569/access_as_user offline_access',
responseType: 'code',
silentRenew: true,
useRefreshToken: true,
maxIdTokenIatOffsetAllowedInSeconds: 600,
issValidationOff: false,
autoUserInfo: false,
logLevel: LogLevel.Debug
},
}),
HttpClientModule,
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true,
},
AuthorizationGuard
],
bootstrap: [AppComponent],
})
export class AppModule {}
import { DirectApiCallComponent } from './directApiCall/directApiCall.component';
import { APP_INITIALIZER, NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { AuthModule, OidcConfigService, LogLevel } from 'angular-auth-oidc-client';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { UnauthorizedComponent } from './unauthorized/unauthorized.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { AuthInterceptor } from './auth.interceptor';
import { NavMenuComponent } from './nav-menu/nav-menu.component';
import { GraphApiCallComponent } from './graphApiCall/graphApiCall.component';
import { ApplicationApiCallComponent } from './applicationApiCall/applicationApiCall.component';
import { DelegatedApiCallComponent } from './delegatedApiCall/delegatedApiCall.component';
import { AuthorizationGuard } from './authorization.guard';

@NgModule({
declarations: [
AppComponent,
HomeComponent,
NavMenuComponent,
UnauthorizedComponent,
DirectApiCallComponent,
GraphApiCallComponent,
ApplicationApiCallComponent,
DelegatedApiCallComponent
],
imports: [
BrowserModule,
RouterModule.forRoot([
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'directApiCall', component: DirectApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'graphApiCall', component: GraphApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'applicationApiCall', component: ApplicationApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'delegatedApiCall', component: DelegatedApiCallComponent, canActivate: [AuthorizationGuard] },
{ path: 'unauthorized', component: UnauthorizedComponent },
], { relativeLinkResolution: 'legacy' }),
AuthModule.forRoot({
config: {
authority: 'https://login.microsoftonline.com/7ff95b15-dc21-4ba6-bc92-824856578fc1/v2.0',
authWellknownEndpointUrl: 'https://login.microsoftonline.com/7ff95b15-dc21-4ba6-bc92-824856578fc1/v2.0',
redirectUrl: window.location.origin,
clientId: 'ad6b0351-92b4-4ee9-ac8d-3e76e5fd1c67',
scope: 'openid profile email api://2b50a014-f353-4c10-aace-024f19a55569/access_as_user offline_access',
responseType: 'code',
silentRenew: true,
useRefreshToken: true,
maxIdTokenIatOffsetAllowedInSeconds: 600,
issValidationOff: false,
autoUserInfo: false,
logLevel: LogLevel.Debug
},
}),
HttpClientModule,
],
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true,
},
AuthorizationGuard
],
bootstrap: [AppComponent],
})
export class AppModule {}
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@



<div *ngIf="isAuthenticated$ | async as isAuthenticated">

<button class="btn btn-primary" type="button" (click)="callApi()" [disabled]="httpRequestRunning">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" [hidden]="!httpRequestRunning" ></span>
Request Data
</button>

<br/><br/>

Is Authenticated: {{ isAuthenticated.isAuthenticated }}

<br/><br/>

<div class="card">
<div class="card-header">Data from API using an Application API</div>
<div class="card-body">
<pre>{{ dataFromAzureProtectedApi$ | async | json }}</pre>
</div>
</div>

</div>



<div *ngIf="isAuthenticated$ | async as isAuthenticated">

<button class="btn btn-primary" type="button" (click)="callApi()" [disabled]="httpRequestRunning">
<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true" [hidden]="!httpRequestRunning" ></span>
Request Data
</button>

<br/><br/>

Is Authenticated: {{ isAuthenticated.isAuthenticated }}

<br/><br/>

<div class="card">
<div class="card-header">Data from API using an Application API</div>
<div class="card-body">
<pre>{{ dataFromAzureProtectedApi$ | async | json }}</pre>
</div>
</div>

</div>

Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { AuthenticatedResult } from 'angular-auth-oidc-client';
import { Observable } from 'rxjs';
import { finalize } from 'rxjs/operators';
import { AuthService } from '../auth.service';

@Component({
selector: 'app-application-api-call',
templateUrl: 'applicationApiCall.component.html',
})
export class ApplicationApiCallComponent implements OnInit {
userData$: Observable<any>;
dataFromAzureProtectedApi$: Observable<any>;
isAuthenticated$: Observable<AuthenticatedResult>;
httpRequestRunning = false;
constructor(
private authService: AuthService,
private httpClient: HttpClient
) {}

ngOnInit() {
this.userData$ = this.authService.userData$;
this.isAuthenticated$ = this.authService.signedIn$;
}
callApi() {
this.httpRequestRunning = true;
this.dataFromAzureProtectedApi$ = this.httpClient
.get('https://localhost:44390/ServiceApiCalls')
.pipe(finalize(() => (this.httpRequestRunning = false)));
}
}
import { HttpClient } from '@angular/common/http';
import { Component, OnInit } from '@angular/core';
import { AuthenticatedResult } from 'angular-auth-oidc-client';
import { Observable } from 'rxjs';
import { finalize } from 'rxjs/operators';
import { AuthService } from '../auth.service';

@Component({
selector: 'app-application-api-call',
templateUrl: 'applicationApiCall.component.html',
})
export class ApplicationApiCallComponent implements OnInit {
userData$: Observable<any>;
dataFromAzureProtectedApi$: Observable<any>;
isAuthenticated$: Observable<AuthenticatedResult>;
httpRequestRunning = false;
constructor(
private authService: AuthService,
private httpClient: HttpClient
) {}

ngOnInit() {
this.userData$ = this.authService.userData$;
this.isAuthenticated$ = this.authService.signedIn$;
}
callApi() {
this.httpRequestRunning = true;
this.dataFromAzureProtectedApi$ = this.httpClient
.get('https://localhost:44390/ServiceApiCalls')
.pipe(finalize(() => (this.httpRequestRunning = false)));
}
}
Loading

0 comments on commit 9308d07

Please sign in to comment.