mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-29 13:18:34 -04:00
Localize notification_utils to the admin
This changeset pulls in all of the notification_utils code directly into the admin and removes it as an external dependency. We are doing this to cut down on operational maintenance of the project and will begin removing parts of it no longer needed for the admin. Signed-off-by: Carlo Costino <carlo.costino@gsa.gov>
This commit is contained in:
13
notifications_utils/url_safe_token.py
Normal file
13
notifications_utils/url_safe_token.py
Normal file
@@ -0,0 +1,13 @@
|
||||
from itsdangerous import URLSafeTimedSerializer
|
||||
|
||||
from notifications_utils.formatters import url_encode_full_stops
|
||||
|
||||
|
||||
def generate_token(payload, secret, salt):
|
||||
return url_encode_full_stops(URLSafeTimedSerializer(secret).dumps(payload, salt))
|
||||
|
||||
|
||||
def check_token(token, secret, salt, max_age_seconds):
|
||||
ser = URLSafeTimedSerializer(secret)
|
||||
payload = ser.loads(token, max_age=max_age_seconds, salt=salt)
|
||||
return payload
|
||||
Reference in New Issue
Block a user