Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
temporary
Browse files Browse the repository at this point in the history
  • Loading branch information
amadolid committed Mar 22, 2024
1 parent 671d2b7 commit 855812b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
8 changes: 2 additions & 6 deletions jaclang_jaseci/securities/authenticator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""Walker API Authenticator."""

from os import getenv
from random import choice
from string import ascii_letters, digits
from typing import Any, Optional, cast

from bson import ObjectId
Expand All @@ -18,12 +16,10 @@
from ..memory import CodeMemory, TokenMemory
from ..models import User
from ..plugins import Root
from ..utils import logger, utc_timestamp
from ..utils import logger, random_string, utc_timestamp


TOKEN_SECRET = getenv(
"TOKEN_SECRET", "".join(choice(ascii_letters + digits) for _ in range(50))
)
TOKEN_SECRET = getenv("TOKEN_SECRET", random_string(50))
TOKEN_ALGORITHM = getenv("TOKEN_ALGORITHM", "HS256")


Expand Down
8 changes: 8 additions & 0 deletions jaclang_jaseci/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
import logging
import sys
from datetime import datetime, timedelta, timezone
from random import choice
from string import ascii_letters, digits
from typing import Optional, Union, cast, get_args, get_origin

from .mail import Emailer, SendGridEmailer


def random_string(length: int) -> str:
"""Generate String with length."""
return "".join(choice(ascii_letters + digits) for _ in range(length))


def utc_datetime(**addons: int) -> datetime:
"""Get current datetime with option to add additional timedelta."""
return datetime.now(tz=timezone.utc) + timedelta(**addons)
Expand All @@ -33,6 +40,7 @@ def make_optional(cls: type) -> type:
__all__ = [
"Emailer",
"SendGridEmailer",
"random_string",
"utc_datetime",
"utc_timestamp",
"logger",
Expand Down

0 comments on commit 855812b

Please sign in to comment.