Skip to content

Commit

Permalink
Some env changes for making the code 'deployable'
Browse files Browse the repository at this point in the history
  • Loading branch information
ErazerBrecht committed Aug 20, 2020
1 parent 7549d77 commit da4e485
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 50 deletions.
6 changes: 3 additions & 3 deletions Erazer.API/Erazer.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="IPAddressRange" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.2" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="IPAddressRange" Version="4.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.7" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion Erazer.API/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{
"idsrv_hostname": "http://localhost:5000",
"mongodb_connectionString": "mongodb://mongo-1:3000,mongo-2:3001/?replicaSet=rs0&readPreference=primary&serverSelectionTimeoutMS=5000&connectTimeoutMS=10000"
}
4 changes: 2 additions & 2 deletions Erazer.IdentityProvider/Erazer.IdentityProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<ItemGroup>
<PackageReference Include="IdentityServer4" Version="3.1.2" />
<PackageReference Include="IPAddressRange" Version="4.0.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
<PackageReference Include="IPAddressRange" Version="4.1.0" />
<PackageReference Include="Serilog.AspNetCore" Version="3.4.0" />
</ItemGroup>
</Project>
26 changes: 0 additions & 26 deletions Erazer.IdentityProvider/LogHeadersMiddleware.cs

This file was deleted.

3 changes: 1 addition & 2 deletions Erazer.IdentityProvider/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
{

}
}
3 changes: 2 additions & 1 deletion Erazer.Web/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module.exports = (apiUrl) => {
// Epoch check
const epochNumber = +epoch;
const now = Date.now();
if (epochNumber < now - 15000 || epochNumber > now + 15000) {
if (epochNumber < now - 10000 || epochNumber > now + 10000) {
return res.status(401).json({ error: 'Signing check failed' });
}

Expand Down Expand Up @@ -56,6 +56,7 @@ module.exports = (apiUrl) => {
decodedSignature,
encoded
);

if (!result) {
return res.status(401).json({ error: 'Signing check failed' });
}
Expand Down
2 changes: 1 addition & 1 deletion Erazer.Web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = new Promise(async (resolve, reject) => {

app.use(redirectMiddleware);
app.use(staticfiles(app.get('config').wwwroot));
app.use('/api', await apiProxy('localhost:5002/'));
app.use('/api', await apiProxy(app.get('config').api));


resolve(app);
Expand Down
1 change: 1 addition & 0 deletions Erazer.Web/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"host": "http://localhost:8888",
"idsrv": "http://localhost:5000",
"api": "http://localhost:5002",
"redis": "redis://localhost:6379"
}
2 changes: 1 addition & 1 deletion Erazer.Web/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = async (app) => {
}));

if (isSecure) {
app.set('trust proxy', 1) // trust first proxy
app.set('trust proxy', true)
}

app.use(session({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { environment } from '../../environments/environment';

@Injectable({providedIn: 'root'})
export class LandingService {
private baseUrl: string;

constructor(private http: HttpClient) {
this.baseUrl = `http://localhost:8888/api`;
this.baseUrl = environment.host + "/api";
}

getMotd(): Observable<string> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const environment = {
production: true,
host: 'http://localhost:5002'
//host: 'https://api.erazerbrecht.me'
host: 'https://erazerbrecht.me'
//host: 'http://localhost:8888'
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

export const environment = {
production: false,
host: 'http://localhost:5002'
host: 'http://localhost:8000'
};
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@ export class TokenInterceptor implements HttpInterceptor {

handle401Error() {
if (isDevMode()) {
// TODO...
alert('Session expired/invalid! Press OK to restart a refresh');
location.reload();
return throwError('Expiration!!');
}
else {
alert('TODO')
return throwError('Redirecting!!');
console.error('Session is unauthenticated. Refresh session...');
window.location.href = "/auth/login";
return throwError('Redirecting...');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { IEnvironment } from "./ienvironment";

export const environment: IEnvironment = {
production: true,
api: 'http://localhost:5002/api',
idsrv: 'http://localhost:5000',
//api: 'https://api.erazerbrecht.me/api',
//idsrv: 'https://login.erazerbrecht.me',
//idsrv: 'http://localhost:5000',
idsrv: 'https://login.erazerbrecht.me',
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { IEnvironment } from "./ienvironment";
// They shouldn't be commited into vcs!!
export const environment: IEnvironment = {
production: false,
api: 'http://localhost:5002/api',
idsrv: 'http://localhost:5000',
username: 'alice',
password: 'alice',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export interface IEnvironment {
production: boolean,
api: string,
idsrv: string,

// DEV only props
Expand Down
3 changes: 2 additions & 1 deletion Erazer.Web/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const wwwroot = __dirname + '/wwwroot';
module.exports = function (app) {
const host = nconf.get('host');
const idsrv = nconf.get('idsrv');
const api = nconf.get('api');
const redis = nconf.get('redis');
const config = { host, idsrv, redis, wwwroot };
const config = { host, idsrv, api, redis, wwwroot };
console.log(`Config: ${JSON.stringify(config)}`);

app.set('config', config);
Expand Down

0 comments on commit da4e485

Please sign in to comment.