admin管理员组文章数量:1122833
I am using Angular v17 and configuration allows for setting subresourceIntegrity
to true
which will add the integrity hash to the <script>
tags that import the compiled Angular project.
This is simple and great, except that it will only use sha384. I need to use a different algorithm for the checksum (TL;DR...using AWS CLI to upload the source files and it does not support SHA384)
I have tried using a custom webpack file and adding the webpack-subresource-integrity with hashFuncNames: ['sha256']
like:
...,
plugins: [
new SubresourceIntegrityPlugin({
enabled: true,
hashFuncNames: ['sha256'],
}),
...
However, if I set subresourceIntegrity
to true in the angular.json options, it seems to ignore my setting and continue to use sha384. If I set subresourceIntegrity
to false, it will not set the integrity attribute.
I'm not as comfortable with webpack as I would like, but tried to create a custom plugin that does something similar and simply don't know enough to get it to work.
Can anyone assist with an example of how to use a fully customizable index.ejs file, custom plugin, existing Angular configuration, etc. to get my compiled index.html file to have something like:
<script src="main.js" integrity="sha256-aof08ans0df8yaf0" crossorigin="anonymous"></script>
I am using Angular v17 and configuration allows for setting subresourceIntegrity
to true
which will add the integrity hash to the <script>
tags that import the compiled Angular project.
This is simple and great, except that it will only use sha384. I need to use a different algorithm for the checksum (TL;DR...using AWS CLI to upload the source files and it does not support SHA384)
I have tried using a custom webpack file and adding the webpack-subresource-integrity with hashFuncNames: ['sha256']
like:
...,
plugins: [
new SubresourceIntegrityPlugin({
enabled: true,
hashFuncNames: ['sha256'],
}),
...
However, if I set subresourceIntegrity
to true in the angular.json options, it seems to ignore my setting and continue to use sha384. If I set subresourceIntegrity
to false, it will not set the integrity attribute.
I'm not as comfortable with webpack as I would like, but tried to create a custom plugin that does something similar and simply don't know enough to get it to work.
Can anyone assist with an example of how to use a fully customizable index.ejs file, custom plugin, existing Angular configuration, etc. to get my compiled index.html file to have something like:
<script src="main.js" integrity="sha256-aof08ans0df8yaf0" crossorigin="anonymous"></script>
Share
Improve this question
asked Nov 22, 2024 at 23:00
Wayne KaskieWayne Kaskie
3,4745 gold badges35 silver badges49 bronze badges
1 Answer
Reset to default 1You have to raise a feature request on Angular Cli Github
to request this customization. Currently it is hard coded to sha384
.
You can mention that deploying to AWS does not support it and it seems like a valid requirement for everyone to use AWS and angular together.
Angular CLI - common.ts Source Code
if (subresourceIntegrity) {
extraPlugins.push(
new SubresourceIntegrityPlugin({
hashFuncNames: ['sha384'],
}),
);
}
本文标签: webpackOverride Subresource Integrity algorithm for Angular buildsStack Overflow
版权声明:本文标题:webpack - Override Subresource Integrity algorithm for Angular builds - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736300441a1930815.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论