-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add SRI integrity hash to assets #3256
Conversation
Sweet, thanks! |
|
||
if ( !empty($assetsConfig['enable_asset_sri']) && $assetsConfig['enable_asset_sri'] ) | ||
{ | ||
$dataToHash = file_get_contents( GRAV_ROOT . $input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@w00fz I think we should cache this part and maybe just check file modification time when hash recalculation isn't needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I agree, also it should probably also use the Grav File instance and locator for the asset content and path, rather than file_get_contents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably merge then optimized to be honest.
|
||
if ( !empty($assetsConfig['enable_asset_sri']) && $assetsConfig['enable_asset_sri'] ) | ||
{ | ||
$dataToHash = file_get_contents( GRAV_ROOT . $input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can probably merge then optimized to be honest.
Having the website pre-generated and hosted on a CDN, I would like to have integrity hashes included in CSS and JS assets.
This PR will allow:
system.assets.enable_asset_sri
config option