-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { DOCUMENT } from '@angular/common'; | ||
import { Inject, Injectable } from '@angular/core'; | ||
import { environment } from '../../environments/environment'; | ||
|
||
/** | ||
* Used to enforce CSP policy. For more details about CSP, see | ||
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy | ||
* and https://developers.google.com/web/fundamentals/security/csp/ | ||
* Evaluate your CSP here: https://csp-evaluator.withgoogle.com/ | ||
* Remove 'unsafe-inline' in style-src once Angular issue is resolved: | ||
* https://github.com/angular/angular/issues/6361 | ||
*/ | ||
@Injectable() | ||
export class CspService { | ||
constructor( | ||
@Inject(DOCUMENT) private doc: Document | ||
) { } | ||
|
||
register() { | ||
if (environment.name !== 'dev') { | ||
const meta: HTMLMetaElement = this.doc.createElement('meta'); | ||
meta.setAttribute('http-equiv', 'Content-Security-Policy'); | ||
meta.setAttribute('content', ` | ||
default-src 'self'; | ||
font-src 'self' data:; | ||
style-src 'self' 'unsafe-inline'; | ||
script-src 'self'; | ||
worker-src 'self'; | ||
object-src 'none'; | ||
form-action 'none'; | ||
frame-src 'none'; | ||
` | ||
); | ||
this.doc.head.appendChild(meta); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const environment = { | ||
name: 'local-prod', | ||
baseHref: '', | ||
isUserNameAutocompleteEnabled: true, | ||
showTokenExpirationCustomization: true, | ||
mockApi: false | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters