Generate a nonce with Apache 2.4 (for a Content Security Policy header)

后端 未结 4 1410
感情败类
感情败类 2020-12-15 12:17

We\'re working on creating a strict Content Security Policy (https://csp.withgoogle.com/docs/strict-csp.html) which necessitates Apache creating a nonce each time a resource

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 12:44

    I would have preferred to simply add this as a comment but my reputation <50 does not allow it so I'm posting this as an answer instead.

    In response to:

    1.) apache generates a random string via mod_unique_id

    This is a "unique" value not a "random" value, so you might want to be careful with its use as a CSP nonce.

    2.) we insert this into our CSP header (not sure how to do this actually)

    
        
            Content-Security-Policy: script-src 'strict-dynamic' 'nonce-%{UNIQUE_ID}e' 'unsafe-inline' ' https:;
        
    
    

    I hope this helps.

提交回复
热议问题