-
-
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.
[CHANGE] Use
django-sri
for sri hashes
- Loading branch information
Showing
9 changed files
with
203 additions
and
60 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
Empty file.
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,39 @@ | ||
""" | ||
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 Fleet Pings | ||
from fleetpings import __title__ | ||
from fleetpings.constants import AA_FLEETPINGS_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-fleetpings/fleetpings/static/fleetpings` folder | ||
:type relative_file_path: str | ||
:return: The integrity hash | ||
:rtype: str | ||
""" | ||
|
||
file_path = os.path.join(AA_FLEETPINGS_STATIC_DIR, relative_file_path) | ||
integrity_hash = calculate_integrity(Path(file_path), 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 fleetpings %} | ||
|
||
<link | ||
rel="stylesheet" | ||
href="{% fleetpings_static 'fleetpings/css/fleetpings.min.css' %}" | ||
integrity="sha512-+QMniThtoDDcrG5vAFSSKJ5ZyxY1m08u0RPoZnw9lZ0ZAWrc4jlZA+9MAS5pZWIzTEJevJChut4aW99JCSvMow==" | ||
crossorigin="anonymous" | ||
> | ||
{% fleetpings_static 'css/fleetpings.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 fleetpings %} | ||
|
||
<script | ||
type="module" | ||
src="{% fleetpings_static 'fleetpings/js/fleetpings.min.js' %}" | ||
integrity="sha512-+WukzJKmxTeDpw6vEQ1DDaPlrhpYwbT3UHYCS33W/gVNUCTkXFMH1bGsAYaqj5FKxioVvQKhD+wMhZdw837C0w==" | ||
crossorigin="anonymous" | ||
></script> | ||
{% fleetpings_static 'js/fleetpings.min.js' 'module' %} |
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