Skip to content

Commit 85f2c37

Browse files
authored
#1649: remove CSP nonce from project (#1664)
* #1649: add new CSP nonce config to project * remove include-nonce-in from settings * drop all uses of nonce * remove cspNonce from index.js * revert formatting issue
1 parent 6b80fc4 commit 85f2c37

5 files changed

Lines changed: 6 additions & 13 deletions

File tree

assets/src/globals.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@ import defaultPalette from './defaultPalette'
55
const mylaGlobalsEl = document.getElementById('myla_globals')
66
const mylaGlobals = mylaGlobalsEl ? JSON.parse(mylaGlobalsEl.textContent) : {}
77

8-
let cspNonce
9-
const cspMetaEl = document.querySelector('meta[name="csp-nonce"]')
10-
if (cspMetaEl !== null & cspMetaEl.hasAttribute('content')) {
11-
cspNonce = cspMetaEl.getAttribute('content')
12-
}
138

149
/*
1510
Frozen to prevent unintentional changes to this object. This object is strictly readonly.
@@ -55,4 +50,4 @@ const siteTheme = createTheme({
5550
})
5651
const gaId = mylaGlobals.google_analytics_id
5752

58-
export { user, siteTheme, gaId, cspNonce, viewHelpURLs, surveyLink }
53+
export { user, siteTheme, gaId, viewHelpURLs, surveyLink }

assets/src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import './index.css'
66
import App from './containers/App'
77
import client from './service/client'
88
import { ApolloProvider } from '@apollo/client'
9-
import { user, siteTheme, gaId, cspNonce } from './globals'
9+
import { user, siteTheme, gaId } from './globals'
1010
// import * as serviceWorker from './serviceWorker'
1111

1212
const container = document.getElementById('root')
@@ -15,7 +15,7 @@ root.render(
1515
<Router basename='/'>
1616
<ApolloProvider client={client}>
1717
<ThemeProvider theme={siteTheme}>
18-
<App user={user} gaId={gaId} cspNonce={cspNonce} />
18+
<App user={user} gaId={gaId} />
1919
</ThemeProvider>
2020
</ApolloProvider>
2121
</Router>

config/env_sample.hjson

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"STYLE":["'unsafe-inline'", "*.umich.edu", "umich.edu", "*.ngrok-free.app"]
3333
},
3434
"UPGRADE_INSECURE_REQUESTS": false,
35-
"INCLUDE_NONCE_IN": ["script-src"]
3635
},
3736
# default password length indicator incase of creating user from command line or LTI auto login
3837
"RANDOM_PASSWORD_DEFAULT_LENGTH": 32,

dashboard/settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ def apply_env_overrides(env: Dict[str, Any], environ: os._Environ) -> Dict[str,
426426
'connect-src': csp_sources["CONNECT"],
427427
'style-src': csp_sources["STYLE"],
428428
'upgrade-insecure-requests': csp_directives["UPGRADE_INSECURE_REQUESTS"],
429-
'include-nonce-in': csp_directives["INCLUDE_NONCE_IN"]
430429
}
431430
}
432431
# If CSP not set, add in XFrameOptionsMiddleware

dashboard/templates/base.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
<!DOCTYPE html>
55
<html lang="en" xmlns="http://www.w3.org/1999/html">
6+
67
<head>
78
<meta charset="utf-8">
89
<meta http-equiv="X-UA-Compatible" content="IE=edge">
910
<meta name="viewport" content="width=device-width, initial-scale=1">
10-
<meta name="csp-nonce" content="{{ request.csp_nonce }}">
1111
<title>{% block title %}{% endblock %}</title>
1212
<link rel="stylesheet" type="text/css" href="{% static 'fontawesomefree/css/all.min.css' %}">
1313
<script src="{% static 'fontawesomefree/js/all.min.js' %}"></script>
@@ -41,7 +41,7 @@
4141
privacyUrl: false
4242
};
4343
</script>
44-
<script async nonce="{{ request.csp_nonce }}" src="https://umich.edu/apis/umconsentmanager/consentmanager.js"></script>
44+
<script async src="https://umich.edu/apis/umconsentmanager/consentmanager.js"></script>
4545
</head>
4646
<body>
4747
{% include "su/is_su.html" %}
@@ -77,4 +77,4 @@
7777
</table>
7878
</footer>
7979
</body>
80-
</html>
80+
</html>

0 commit comments

Comments
 (0)