Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Remove Google API keys from repository into shared secrets file
Browse files Browse the repository at this point in the history
  • Loading branch information
maurizi committed Mar 1, 2019
1 parent a616153 commit 2b384fb
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
5 changes: 1 addition & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ node {

stage('test') {
wrap([$class: 'AnsiColorBuildWrapper']) {
writeFile file: 'src/app/constants.ts', text: """
export const defaultCity = {\'id\': 7, \'properties\': {\'name\': \'Philadelphia\', \'admin\': \'PA\'}};
export const apiHost = \'${env.API_HOST}\';
export const defaultScenario = \'RCP85\';\n"""
sh "aws s3 cp 's3://${env.CC_SETTINGS_BUCKET}/angular/constants.ts' 'src/app/constants.ts'"

sh './scripts/test --jenkins'

Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ Alternatively, you can bring up the vagrant VM that has the dependencies install
If your development host machine meets the requirements above, simply:

- Clone this repo and run `yarn install`
- `cp example/constants.ts.example src/app/constants.ts`
- Edit `constants.ts` to set the API server name
- Copy the "Climate lab dev config" from LastPass to `src/app/constants.ts` (See below if you do not have access to this resource)
- `yarn run serve`

The site will then be available at [http://localhost:4200](http://localhost:4200) on your host machine.

#### Setting up constants.ts

For users who don't have access to our internal configuration file, you can create your own with the following steps:
- Enable the "Maps JavaScript API" and "Places API" from the [Google API library](https://console.cloud.google.com/apis/library), then create a new [Google API key](https://console.cloud.google.com/apis/credentials/). You can restrict it to the "Maps JavaScript API" and "Places API" with referrers set to `http://localhost:4200/*`
- `cp example/constants.ts.example src/app/constants.ts`
- Edit `constants.ts` to set the API server name and Google API key

### Setup via Vagrant VM

_Recommended only if you don't have the requirements above installed on your host system and are unable to install. If you do, strongly consider instructions in #Setup instead._
Expand Down
1 change: 1 addition & 0 deletions example/constants.ts.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
*/

export const apiHost = 'https://app.climate.azavea.com';
export const googleApiKey = 'Add API key here';
5 changes: 2 additions & 3 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ import { ImageExportService } from './services/image-export.service';
import { MapCellService } from './services/map-cell.service';
import { ProjectService } from './services/project.service';

import { apiHost } from './constants';
import { environment } from '../environments/environment';
import { apiHost, googleApiKey } from './constants';

// Custom app providers
const locationStrategyProvider = {
Expand All @@ -60,7 +59,7 @@ const locationStrategyProvider = {

// Google maps config
const AGM_CONFIG = {
apiKey: environment.googleMapsApiKey,
apiKey: googleApiKey,
libraries: ['places']
};

Expand Down
1 change: 0 additions & 1 deletion src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const environment = {
production: true,
distance: 32000,
googleMapsApiKey: 'AIzaSyDbVOdIZAq4rBo94p947kCBo_KKPyqFf9I',
};
1 change: 0 additions & 1 deletion src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
export const environment = {
production: false,
distance: 32000,
googleMapsApiKey: 'AIzaSyCUvxTzvJ9kGEu2S7U641D7QGt5Xym0DjM',
};

0 comments on commit 2b384fb

Please sign in to comment.