original_docstring: 
      Decodes and validates the JWT token passed in the GET request to a
      /webapp endpoint.
  
      Adds two items to ``r.session``:
      - authenticated: a boolean for whether the session has been authenticated
          for any transaction
      - account: the stellar account address associated with the token
      
docstring: Decodes and validates the JWT token passed in the GET request to a
  webapp endpoint.
  
  Adds two items to ``r.session``:
  authenticated: a boolean for whether the session has been authenticated
  for any transaction
  account: the stellar account address associated with the token
docstring_tokens: Decodes and validates the JWT token passed in the GET request to a webapp endpoint . Adds two items to ` ` r . session ` ` : authenticated : a boolean for whether the session has been authenticated for any transaction account : the stellar account address associated with the token
code: def authenticate_session_helper(r: Request):
      """
      Decodes and validates the JWT token passed in the GET request to a
      /webapp endpoint.
  
      Adds two items to ``r.session``:
      - authenticated: a boolean for whether the session has been authenticated
          for any transaction
      - account: the stellar account address associated with the token
      """
      # Don't authenticate in local mode, since session cookies will not be
      # included in request/response headers without HTTPS
      if settings.LOCAL_MODE:
          return
  
      token = r.GET.get("token")
      if not token:
          # If there is no token, check if this session has already been authenticated,
          # that the session's account is the one that initiated the transaction, and
          # that the session has been authenticated for this particular transaction.
          if r.session.get("authenticated") and r.session.get("account", ""):
              tid = r.GET.get("transaction_id")
              tqs = Transaction.objects.filter(
                  id=tid, stellar_account=r.session["account"]
              )
              if not (tid in r.session.get("transactions", []) and tqs.exists()):
                  raise ValueError(f"Not authenticated for transaction ID: {tid}")
              else:  # pragma: no cover
                  # client has been authenticated for the requested transaction
                  return
          else:
              raise ValueError("Missing authentication token")
  
      try:
          jwt_dict = jwt.decode(token, settings.SERVER_JWT_KEY, algorithms=["HS256"])
      except InvalidTokenError as e:
          raise ValueError(str(e))
  
      now = time.time()
      if jwt_dict["iss"] != r.build_absolute_uri("interactive"):
          raise ValueError(_("Invalid token issuer"))
      elif jwt_dict["iat"] > now or jwt_dict["exp"] < now:
          raise ValueError(_("Token is not yet valid or is expired"))
  
      transaction_qs = Transaction.objects.filter(
          id=jwt_dict["jti"], stellar_account=jwt_dict["sub"]
      )
      if not transaction_qs.exists():
          raise ValueError(_("Transaction for account not found"))
  
      # JWT is valid, authenticate session
      r.session["authenticated"] = True
      r.session["account"] = jwt_dict["sub"]
      try:
          r.session["transactions"].append(jwt_dict["jti"])
      except KeyError:
          r.session["transactions"] = [jwt_dict["jti"]]
code_tokens: def authenticate_session_helper ( r : Request ) : if settings . LOCAL_MODE : return token = r . GET . get ( "token" ) if not token : if r . session . get ( "authenticated" ) and r . session . get ( "account" , "" ) : tid = r . GET . get ( "transaction_id" ) tqs = Transaction . objects . filter ( id = tid , stellar_account = r . session [ "account" ] ) if not ( tid in r . session . get ( "transactions" , [ ] ) and tqs . exists ( ) ) : raise ValueError ( f"Not authenticated for transaction ID: {tid}" ) else : return else : raise ValueError ( "Missing authentication token" ) try : jwt_dict = jwt . decode ( token , settings . SERVER_JWT_KEY , algorithms = [ "HS256" ] ) except InvalidTokenError as e : raise ValueError ( str ( e ) ) now = time . time ( ) if jwt_dict [ "iss" ] != r . build_absolute_uri ( "interactive" ) : raise ValueError ( _ ( "Invalid token issuer" ) ) elif jwt_dict [ "iat" ] > now or jwt_dict [ "exp" ] < now : raise ValueError ( _ ( "Token is not yet valid or is expired" ) ) transaction_qs = Transaction . objects . filter ( id = jwt_dict [ "jti" ] , stellar_account = jwt_dict [ "sub" ] ) if not transaction_qs . exists ( ) : raise ValueError ( _ ( "Transaction for account not found" ) ) r . session [ "authenticated" ] = True r . session [ "account" ] = jwt_dict [ "sub" ] try : r . session [ "transactions" ] . append ( jwt_dict [ "jti" ] ) except KeyError : r . session [ "transactions" ] = [ jwt_dict [ "jti" ] ]
short_docstring: Decodes and validates the JWT token passed in the GET request to a
  webapp endpoint.
short_docstring_tokens: Decodes and validates the JWT token passed in the GET request to a webapp endpoint .
comment: """
      Decodes and validates the JWT token passed in the GET request to a
      /webapp endpoint.
  
      Adds two items to ``r.session``:
      - authenticated: a boolean for whether the session has been authenticated
          for any transaction
      - account: the stellar account address associated with the token
      """$SEP$# Don't authenticate in local mode, since session cookies will not be$SEP$# included in request/response headers without HTTPS$SEP$# If there is no token, check if this session has already been authenticated,$SEP$# that the session's account is the one that initiated the transaction, and$SEP$# that the session has been authenticated for this particular transaction.$SEP$# pragma: no cover$SEP$# client has been authenticated for the requested transaction$SEP$# JWT is valid, authenticate session