MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / GenerateCSPString

Function GenerateCSPString

pkg/identityserver/identityserver.go:90–124  ·  view source on GitHub ↗

GenerateCSPString returns a Content-Security-Policy header value for OAuth and Account app template.

(config *oauth.Config, nonce string)

Source from the content-addressed store, hash-verified

88// GenerateCSPString returns a Content-Security-Policy header value
89// for OAuth and Account app template.
90func GenerateCSPString(config *oauth.Config, nonce string) string {
91 baseURLs := webui.RewriteSchemes(
92 webui.WebsocketSchemeRewrites,
93 config.UI.StackConfig.IS.BaseURL,
94 )
95 return webui.ContentSecurityPolicy{
96 ConnectionSource: append([]string{
97 "'self'",
98 config.UI.SentryDSN,
99 config.UI.StatusPage,
100 "gravatar.com",
101 "www.gravatar.com",
102 }, baseURLs...),
103 StyleSource: []string{
104 "'self'",
105 config.UI.AssetsBaseURL,
106 config.UI.BrandingBaseURL,
107 "'unsafe-inline'",
108 },
109 ScriptSource: []string{
110 "'self'",
111 config.UI.AssetsBaseURL,
112 config.UI.BrandingBaseURL,
113 "'unsafe-eval'",
114 "'strict-dynamic'",
115 fmt.Sprintf("'nonce-%s'", nonce),
116 },
117 BaseURI: []string{
118 "'self'",
119 },
120 FrameAncestors: []string{
121 "'none'",
122 },
123 }.Clean().String()
124}
125
126type accountAppStore struct {
127 store.TransactionalStore

Callers

nothing calls this directly

Calls 3

RewriteSchemesFunction · 0.92
StringMethod · 0.65
CleanMethod · 0.45

Tested by

no test coverage detected