reformat private key

This commit is contained in:
Kenneth Kehl
2023-12-15 12:07:54 -08:00
parent bc32c62dc6
commit cec2d7ea02
2 changed files with 26 additions and 2 deletions

View File

@@ -22,15 +22,28 @@ from app.main import main
from app.main.forms import LoginForm
from app.main.views.verify import activate_user
from app.models.user import InvitedUser, User
from app.utils import hide_from_search_engines, hilite
from app.utils import hide_from_search_engines
from app.utils.login import is_safe_redirect_url
def _reformulate_keystring(orig):
new_keystring = orig.replace("-----BEGIN PRIVATE KEY-----", "")
new_keystring = new_keystring.replace("-----END PRIVATE KEY-----", "")
new_keystring = new_keystring.strip()
new_keystring = "\n".join(
["-----BEGIN PRIVATE KEY-----", new_keystring, "-----END PRIVATE KEY-----"]
)
new_keystring = f"{new_keystring}\n"
return new_keystring
def _get_access_token(code, state):
client_id = os.getenv("LOGIN_DOT_GOV_CLIENT_ID")
access_token_url = os.getenv("LOGIN_DOT_GOV_ACCESS_TOKEN_URL")
keystring = os.getenv("LOGIN_PEM")
print(hilite(f"LOGIN_PEM: START{keystring}FINISH")) # noqa temp
if " " in keystring:
keystring = _reformulate_keystring(keystring)
payload = {
"iss": client_id,
"sub": client_id,