-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Support strict CSP policies for style-src 'self' #12139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@lightswitch05 does this apply to |
@jelbourn great question, I'm not sure. I guess I need to put together a test page to see what is allowed and what isnt |
I suspect it doesn't, since Angular converts those into JS instructions, but it would be good to make sure. The static ones should be pretty trivial to convert to css classes. |
I thought this was limited to Material, however in trying to setup some basic example pages I found the issue goes to the core of Angular, so this ticket is no longer relevant. Any bare basics angular page with a strict style CSP fails. [source] [example] Looks like its a known issue: angular/angular#6361 |
No offense @lightswitch05 , I have to disagree. You have a choice to define your styles globally and with the My question is why are the Angular Material components inlining the styles when I'm using the Angular Material SASS API to generate the styles anyways? If its possible, I'd recommend centralizing (moving) those inline styles into the SASS API that is already established. This would resolve the CSP issue and allow developers, such as myself, to use Angular Material components in more restrictive environments. P.S. I am a fairly capable front-end developer and would be glad to contribute some time to help resolve this issue. |
After looking at the code a bit, I understand how the styles are separated. The styles generated by the SASS API are more theme-related and the inline component styles are more layout related. However, I still think centralizing the styles has its merits. The theme API could import the component style files from their current location to keep it maintainable and to keep the styles close to their related component files. |
It looks like most of the components are already using |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Feature Request
Angular material is currently incompatible with a strict Content Security Policy (CSP) of
style-src 'self';
. The most strict CSP policy for style-src that I've been able to use with Angular Material isstyle-src 'self' 'unsafe-inline';
, which isn't terrible, but still gets flagged on security scanners like https://csp-evaluator.withgoogle.comIt would be nice if Angular Material could become compatible with strict CSPs. What it would mean is removing any in-line style tags, such as the one in checkbox.html
Questions
The text was updated successfully, but these errors were encountered: