Skip to content

Commit 7d10487

Browse files
authored
Changes need to deploy to Azure (elanderson#18)
1 parent 18677bb commit 7d10487

27 files changed

+17517
-41242
lines changed

ApiApp/Startup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void ConfigureServices(IServiceCollection services)
2424
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
2525
}).AddJwtBearer(o =>
2626
{
27-
o.Authority = "http://localhost:5000";
27+
o.Authority = Configuration["IdentityServerAddress"];
2828
o.Audience = "apiApp";
2929
o.RequireHttpsMetadata = false;
3030
});
@@ -33,7 +33,7 @@ public void ConfigureServices(IServiceCollection services)
3333
{
3434
options.AddPolicy("default", policy =>
3535
{
36-
policy.WithOrigins("http://localhost:5002")
36+
policy.WithOrigins(Configuration["ClientAddress"])
3737
.AllowAnyHeader()
3838
.AllowAnyMethod();
3939
});

ApiApp/appsettings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
"LogLevel": {
55
"Default": "Warning"
66
}
7-
}
7+
},
8+
"IdentityServerAddress": "http://localhost:5000",
9+
"ClientAddress": "http://localhost:5002"
810
}

ClientApp/ClientApp/app/app.module.browser.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,23 @@ import { AppComponent } from './components/app/app.component';
1010
AppModuleShared
1111
],
1212
providers: [
13+
{ provide: 'ORIGIN_URL', useFactory: getBaseUrl },
14+
{ provide: 'API_URL', useFactory: apiUrlFactory },
15+
{ provide: 'IDENTITY_URL', useFactory: identityUrlFactory },
1316
AppModuleShared
1417
]
1518
})
1619
export class AppModule {
1720
}
1821

22+
export function getBaseUrl() {
23+
return document.getElementsByTagName('base')[0].href;
24+
}
25+
26+
export function apiUrlFactory() {
27+
return (window as any).url_Config.apiUrl;
28+
}
1929

30+
export function identityUrlFactory() {
31+
return (window as any).url_Config.identityUrl;
32+
}

ClientApp/ClientApp/app/app.module.shared.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,9 @@ import { AuthService } from './components/services/auth.service';
3939
],
4040
providers: [
4141
AuthService,
42-
OidcSecurityService,
43-
{ provide: 'ORIGIN_URL', useFactory: getBaseUrl },
44-
{ provide: 'API_URL', useFactory: getApiUrl }
42+
OidcSecurityService
4543
]
4644
})
4745
export class AppModuleShared {
4846
}
4947

50-
export function getBaseUrl() {
51-
return document.getElementsByTagName('base')[0].href;
52-
}
53-
54-
export function getApiUrl() {
55-
return "http://localhost:5001/api/";
56-
}

ClientApp/ClientApp/app/components/services/auth.service.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, Component, OnInit, OnDestroy } from '@angular/core';
1+
import { Injectable, Component, OnInit, OnDestroy, Inject } from '@angular/core';
22
import { Http, Headers, RequestOptions, Response } from '@angular/http';
33
import { Observable } from 'rxjs/Rx';
44
import { Subscription } from 'rxjs/Subscription';
@@ -11,15 +11,17 @@ export class AuthService implements OnInit, OnDestroy {
1111
isAuthorized: boolean;
1212

1313
constructor(public oidcSecurityService: OidcSecurityService,
14-
private http: Http) {
15-
14+
private http: Http,
15+
@Inject('ORIGIN_URL') originUrl: string,
16+
@Inject('IDENTITY_URL') identityUrl: string
17+
) {
1618
const openIdImplicitFlowConfiguration = new OpenIDImplicitFlowConfiguration();
17-
openIdImplicitFlowConfiguration.stsServer = 'http://localhost:5000';
18-
openIdImplicitFlowConfiguration.redirect_url = 'http://localhost:5002/callback';
19+
openIdImplicitFlowConfiguration.stsServer = identityUrl;
20+
openIdImplicitFlowConfiguration.redirect_url = originUrl + 'callback';
1921
openIdImplicitFlowConfiguration.client_id = 'ng';
2022
openIdImplicitFlowConfiguration.response_type = 'id_token token';
2123
openIdImplicitFlowConfiguration.scope = 'openid profile apiApp';
22-
openIdImplicitFlowConfiguration.post_logout_redirect_uri = 'http://localhost:5002/home';
24+
openIdImplicitFlowConfiguration.post_logout_redirect_uri = originUrl + 'home';
2325
openIdImplicitFlowConfiguration.startup_route = '/home';
2426
openIdImplicitFlowConfiguration.forbidden_route = '/forbidden';
2527
openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized';

ClientApp/ClientApp/boot.server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ export default createServerRenderer(params => {
1414
{ provide: INITIAL_CONFIG, useValue: { document: '<app></app>', url: params.url } },
1515
{ provide: APP_BASE_HREF, useValue: params.baseUrl },
1616
{ provide: 'BASE_URL', useValue: params.origin + params.baseUrl },
17+
{ provide: 'ORIGIN_URL', useValue: params.origin + params.baseUrl },
18+
{ provide: 'API_URL', useValue: params.data.apiUrl },
19+
{ provide: 'IDENTITY_URL', useValue: params.data.identityUrl },
20+
{ provide: 'URL_CONFIG', useValue: params.data}
1721
];
1822

1923
return platformDynamicServer(providers).bootstrapModule(AppModule).then(moduleRef => {
@@ -28,7 +32,8 @@ export default createServerRenderer(params => {
2832
// completing the request in case there's an error to report
2933
setImmediate(() => {
3034
resolve({
31-
html: state.renderToString()
35+
html: state.renderToString(),
36+
globals: {url_Config: params.data}
3237
});
3338
moduleRef.destroy();
3439
});

0 commit comments

Comments
 (0)