-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #254 from ppfeufer/django-sri
- Loading branch information
Showing
16 changed files
with
221 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Helper functions for static integrity calculations | ||
""" | ||
|
||
# Standard Library | ||
import os | ||
from pathlib import Path | ||
|
||
# Third Party | ||
from sri import Algorithm, calculate_integrity | ||
|
||
# Alliance Auth | ||
from allianceauth.services.hooks import get_extension_logger | ||
|
||
# Alliance Auth (External Libs) | ||
from app_utils.logging import LoggerAddTag | ||
|
||
# AA SRP | ||
from aasrp import __title__ | ||
from aasrp.constants import AA_SRP_STATIC_DIR | ||
|
||
logger = LoggerAddTag(my_logger=get_extension_logger(__name__), prefix=__title__) | ||
|
||
|
||
def calculate_integrity_hash(relative_file_path: str) -> str: | ||
""" | ||
Calculates the integrity hash for a given static file | ||
:param self: | ||
:type self: | ||
:param relative_file_path: The file path relative to the `aa-srp/aasrp/static/aasrp` folder | ||
:type relative_file_path: str | ||
:return: The integrity hash | ||
:rtype: str | ||
""" | ||
|
||
file_path = os.path.join(AA_SRP_STATIC_DIR, relative_file_path) | ||
integrity_hash = calculate_integrity( | ||
path=Path(file_path), algorithm=Algorithm.SHA512 | ||
) | ||
|
||
return integrity_hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<link | ||
rel="stylesheet" | ||
href="{% aasrp_static 'aasrp/css/aa-srp.min.css' %}" | ||
integrity="sha512-eeN/pqBQ+41AVmNR+UyHjrSZvK0fpd5c14yV4NHnQEEXseMMZQu794m/PJ4usfZyQnZS2t4kFWDusnWZhC+HWw==" | ||
crossorigin="anonymous" | ||
> | ||
{% aasrp_static "css/aa-srp.min.css" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<link | ||
rel="stylesheet" | ||
href="{% aasrp_static 'aasrp/css/aa-srp-form.min.css' %}" | ||
integrity="sha512-y6ANPtPgBNxGQhYYNN3EI5bpLtzy/IVAJ18I5MdjnCIel2fCnD34H3dkHdOpt8ZiaKb9T/NRjS5rxlQynP9hlQ==" | ||
crossorigin="anonymous" | ||
> | ||
{% aasrp_static "css/aa-srp-form.min.css" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<script | ||
src="{% aasrp_static 'aasrp/javascript/form.min.js' %}" | ||
integrity="sha512-ln1VzEG3ExrwRcfqIxE9WUXh81N4t2LJSq+bLrMGx4m1X/kwxbtSpDGD7EMwsDgtRCxKecPrnvw2VRf5lG8M9w==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% aasrp_static "javascript/form.min.js" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<script | ||
src="{% aasrp_static 'aasrp/javascript/aa-srp.min.js' %}" | ||
integrity="sha512-SKL5pQAdZ1elLpwQNAi7E/kiO9txWBFPyYzCuClBx4psUpPwezz0LviMO8VEO09m0C7/q1KWLZPxXNJA/Igwxg==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% aasrp_static "javascript/aa-srp.min.js" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<script | ||
src="{% aasrp_static 'aasrp/javascript/my-srp-requests.min.js' %}" | ||
integrity="sha512-HAmMdsguzaj4WiEQFNjvu6ykL70u/Tucj8aggl5grtLcSHNq8+Qcqi+oAhR02DI6WI04WfsFGVsIZsiPiHbohQ==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% aasrp_static "javascript/my-srp-requests.min.js" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<script | ||
src="{% aasrp_static 'aasrp/javascript/srp-links.min.js' %}" | ||
integrity="sha512-qIB1r3Oqer36+Ujp4Y/cihZVpUf3mAEYerpQ2UqIjVkLpPMHAqoSOrf+wGq22isAKTjfSK4+9GWJlHbLnViaTw==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% aasrp_static "javascript/srp-links.min.js" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load aasrp %} | ||
|
||
<script | ||
src="{% aasrp_static 'aasrp/javascript/view-requests.min.js' %}" | ||
integrity="sha512-OX093crku4t8qUaI+nb6M29X6XPXNcikn/yZcjYEGq0VeP4f862u3uynXwky/MkFKOHBucuaPLDjcCU7RGhrKQ==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% aasrp_static "javascript/view-requests.min.js" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
{% load static %} | ||
{% load aasrp %} | ||
|
||
<link | ||
rel="stylesheet" | ||
href="{% static 'aasrp/libs/x-editable/1.5.4/bootstrap5-editable/css/bootstrap-editable.min.css' %}" | ||
integrity="sha512-52DL7BCZnjDkln1qrZMe9qSt6KFBwrGAa4JqmrmwYrz+QIfBXyacLvmTrpIyqJdjcEqzw/3YOM4Xj32mDz4x3A==" | ||
crossorigin="anonymous" | ||
> | ||
{% aasrp_static "libs/x-editable/1.5.4/bootstrap5-editable/css/bootstrap-editable.min.css" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
{% load static %} | ||
{% load aasrp %} | ||
|
||
<script | ||
src="{% static 'aasrp/libs/x-editable/1.5.4/bootstrap5-editable/js/bootstrap-editable.min.js' %}" | ||
integrity="sha512-GpwuhZ2LkD9jnasqgssH1FJQLHvIeW9T36ax9W3dv+8KSA3xURDoTffS1SD95KSb2fXuYWg0Z5sDoZ/Xx10GHA==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% aasrp_static "libs/x-editable/1.5.4/bootstrap5-editable/js/bootstrap-editable.min.js" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.