Skip to content

Commit

Permalink
Changes need to deploy to Azure (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
elanderson authored Oct 3, 2017
1 parent 18677bb commit 7d10487
Show file tree
Hide file tree
Showing 27 changed files with 17,517 additions and 41,242 deletions.
4 changes: 2 additions & 2 deletions ApiApp/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void ConfigureServices(IServiceCollection services)
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
}).AddJwtBearer(o =>
{
o.Authority = "http://localhost:5000";
o.Authority = Configuration["IdentityServerAddress"];
o.Audience = "apiApp";
o.RequireHttpsMetadata = false;
});
Expand All @@ -33,7 +33,7 @@ public void ConfigureServices(IServiceCollection services)
{
options.AddPolicy("default", policy =>
{
policy.WithOrigins("http://localhost:5002")
policy.WithOrigins(Configuration["ClientAddress"])
.AllowAnyHeader()
.AllowAnyMethod();
});
Expand Down
4 changes: 3 additions & 1 deletion ApiApp/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"LogLevel": {
"Default": "Warning"
}
}
},
"IdentityServerAddress": "http://localhost:5000",
"ClientAddress": "http://localhost:5002"
}
13 changes: 13 additions & 0 deletions ClientApp/ClientApp/app/app.module.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@ import { AppComponent } from './components/app/app.component';
AppModuleShared
],
providers: [
{ provide: 'ORIGIN_URL', useFactory: getBaseUrl },
{ provide: 'API_URL', useFactory: apiUrlFactory },
{ provide: 'IDENTITY_URL', useFactory: identityUrlFactory },
AppModuleShared
]
})
export class AppModule {
}

export function getBaseUrl() {
return document.getElementsByTagName('base')[0].href;
}

export function apiUrlFactory() {
return (window as any).url_Config.apiUrl;
}

export function identityUrlFactory() {
return (window as any).url_Config.identityUrl;
}
11 changes: 1 addition & 10 deletions ClientApp/ClientApp/app/app.module.shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,9 @@ import { AuthService } from './components/services/auth.service';
],
providers: [
AuthService,
OidcSecurityService,
{ provide: 'ORIGIN_URL', useFactory: getBaseUrl },
{ provide: 'API_URL', useFactory: getApiUrl }
OidcSecurityService
]
})
export class AppModuleShared {
}

export function getBaseUrl() {
return document.getElementsByTagName('base')[0].href;
}

export function getApiUrl() {
return "http://localhost:5001/api/";
}
14 changes: 8 additions & 6 deletions ClientApp/ClientApp/app/components/services/auth.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Component, OnInit, OnDestroy } from '@angular/core';
import { Injectable, Component, OnInit, OnDestroy, Inject } from '@angular/core';
import { Http, Headers, RequestOptions, Response } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Subscription } from 'rxjs/Subscription';
Expand All @@ -11,15 +11,17 @@ export class AuthService implements OnInit, OnDestroy {
isAuthorized: boolean;

constructor(public oidcSecurityService: OidcSecurityService,
private http: Http) {

private http: Http,
@Inject('ORIGIN_URL') originUrl: string,
@Inject('IDENTITY_URL') identityUrl: string
) {
const openIdImplicitFlowConfiguration = new OpenIDImplicitFlowConfiguration();
openIdImplicitFlowConfiguration.stsServer = 'http://localhost:5000';
openIdImplicitFlowConfiguration.redirect_url = 'http://localhost:5002/callback';
openIdImplicitFlowConfiguration.stsServer = identityUrl;
openIdImplicitFlowConfiguration.redirect_url = originUrl + 'callback';
openIdImplicitFlowConfiguration.client_id = 'ng';
openIdImplicitFlowConfiguration.response_type = 'id_token token';
openIdImplicitFlowConfiguration.scope = 'openid profile apiApp';
openIdImplicitFlowConfiguration.post_logout_redirect_uri = 'http://localhost:5002/home';
openIdImplicitFlowConfiguration.post_logout_redirect_uri = originUrl + 'home';
openIdImplicitFlowConfiguration.startup_route = '/home';
openIdImplicitFlowConfiguration.forbidden_route = '/forbidden';
openIdImplicitFlowConfiguration.unauthorized_route = '/unauthorized';
Expand Down
7 changes: 6 additions & 1 deletion ClientApp/ClientApp/boot.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ export default createServerRenderer(params => {
{ provide: INITIAL_CONFIG, useValue: { document: '<app></app>', url: params.url } },
{ provide: APP_BASE_HREF, useValue: params.baseUrl },
{ provide: 'BASE_URL', useValue: params.origin + params.baseUrl },
{ provide: 'ORIGIN_URL', useValue: params.origin + params.baseUrl },
{ provide: 'API_URL', useValue: params.data.apiUrl },
{ provide: 'IDENTITY_URL', useValue: params.data.identityUrl },
{ provide: 'URL_CONFIG', useValue: params.data}
];

return platformDynamicServer(providers).bootstrapModule(AppModule).then(moduleRef => {
Expand All @@ -28,7 +32,8 @@ export default createServerRenderer(params => {
// completing the request in case there's an error to report
setImmediate(() => {
resolve({
html: state.renderToString()
html: state.renderToString(),
globals: {url_Config: params.data}
});
moduleRef.destroy();
});
Expand Down
Loading

0 comments on commit 7d10487

Please sign in to comment.