Skip to content

Commit

Permalink
fix: make id_token,access_token accessible by JS
Browse files Browse the repository at this point in the history
  • Loading branch information
burib authored Jan 4, 2025
1 parent 618e6d3 commit 20f8f79
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions functions/lambda_at_edge/auth_check.tpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,24 @@ def format_cookie_date(timestamp):
"""Convert Unix timestamp to cookie-compatible date format"""
return formatdate(timestamp, usegmt=True)

def create_cookie_header(name, value, expiration=None, path="/"):
"""Create a cookie header with security attributes and expiration"""
cookie = f"{name}={value}; Secure; HttpOnly; SameSite=Lax; Path={path}"
def create_cookie_header(name, value, expiration=None, path="/", http_only=False):
"""Create a cookie header with security attributes and expiration
Args:
name: Cookie name
value: Cookie value
expiration: Optional expiration datetime
path: Cookie path (default: "/")
http_only: Whether cookie should be HttpOnly (default: False)
"""
cookie = f"{name}={value}; Secure; SameSite=Lax; Path={path}"

if http_only:
cookie += "; HttpOnly"

if expiration:
cookie += f"; Expires={format_cookie_date(expiration)}"

return cookie

# Update the handler function's protected path check
Expand Down

0 comments on commit 20f8f79

Please sign in to comment.