def apply_to_headers(self, headers: Headers) -> Headers: """ Apply access control headerst to the supplied headers and return them. """ headers.add('Access-Control-Allow-Headers', self._allowed_headers) headers.add('Access-Control-Allow-Methods', self._ALLOWED_METHODS), headers.add('Access-Control-Allow-Credentials', self._ALLOW_CREDENTIALS) return headers
def flag_signout(cls: Type[T], debug: bool, configuration: Configuration, existing_headers: Optional[Headers] = None) -> Headers: existing = existing_headers headers = Headers() if existing is not None: assert isinstance(existing, Headers) headers = existing headers.add( 'Set-Cookie', cls.generate_flag_cookie(logged_in=False, debug=debug, configuration=configuration)) return headers
def __init__(self, session: Session, configuration: Configuration, existing: Optional[Headers] = None) -> None: assert isinstance(session, Session) self._debug = configuration.debug self._configuration = configuration self._session = session headers = Headers() if existing is not None: assert isinstance(existing, Headers) headers = existing headers.add('Set-Cookie', self._generate_session_cookie(self._debug)) headers.add('Set-Cookie', self._generate_key_cookie(self._debug)) headers.add( 'Set-Cookie', self.generate_flag_cookie(logged_in=True, debug=configuration.debug, configuration=configuration)) self._raw = headers.dictionary super().__init__(headers) return
def apply_to_headers(self, headers: Headers) -> Headers: """Return Headers with CORS policy applied""" headers.add(self._HEADER_KEY, self.allowed_origin) return headers
def apply_to_headers(self, headers: Headers) -> Headers: """Apply server name to headers and return them""" headers.add('Server', self._configuration.server_name) return headers
def simulate_cookie_headers(self, debug: bool = True) -> Headers: headers = Headers() headers.add('Cookie', self.simulate_cookie(debug)) return headers