-
Notifications
You must be signed in to change notification settings - Fork 51
CSP compliances #93
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
CSP compliances #93
Conversation
+ fix reference to `sb-admin.min.css` in `logout.html`
Fix typo
Fix HTML inline `onclick` events and `onsubmit` for forms
|
Thanks, and welcome to the Contributors. I'll test it soon and get back to you. |
|
Hey @mkalioby, did you perhaps got any time to test the changes? If you need anything, just let me know! ;) |
|
I didn't have time so far, I'll try my best during the weekend. |
|
@lvanbuiten Please excuse my ignorance. I think we shall do something in example code, so we show the users how to enforce CSP. As for me, I don't really know what so I change in my project to enforce CSP and make sure it really works. Thanks for the great work. |
|
@mkalioby No worries at all! It's neither my specialty, but something we have enabled in our django application and therefore would like contribute in order to not lower our enforcement. I'll try my best and with my best knowledge explain CSP and the possible impact of CSP explained
With CSP rules in place, depending on the configuration of course, you are not allowed to serve inline CSS and Javascript within HTML files. The reason is, that someone could perform a man-in-the-middle attack and serve malicious content. The browser can validate the origin with CSS and Javascript files and match them against the provide CSP rules. If the origin doesn't match any of the rules, the browser will block the content and therefor doesn't serve it to the client's browser. Impact for django-mfa (Usage)In general there doesn't changes anything for the usage of The owner of the django application, so like me, chooses to enable and enforce CSP rules. We use Django-CSP, current version 3.8, to archive that goal. With the following changes you can, in theory, enable CSP in your application. When violating these rules, with Impact for django-mfa (Maintenance / Contribution)For contributing or maintaining |
|
Hey @mkalioby, Did you perhaps had any chance to proceed testing the changes or can i help you in any way? |
|
Hello @lvanbuiten I'm still working on it. |
|
Thanks @lvanbuiten , all good. |
|
LGTM! |

Pull request containing changes to make this app/module Content Security Policy(CSP) compliant, by removing all inline styling and scripting by moving it to separate (static) CSS/JavaScript files.
The
onclickandonsubmitevents are added in the JavaScript files upon document ready hook.Dynamic content for scripting in mostly passed through by
json_script, with one exception forMFA.htmlwhich is done by data-attributes.I've thoroughly tested FIDO2, TOTP and Recovery Codes since I have everything setup for that. For the other methods I stepped through the flows and compared it against the original example app and noticed no differences.
PR is to branch v3.1 since this included changes of #53 (delete key).
Credits: Based the inspiration and some of the techniques of AndreasDickow