Skip to content

Commit

Permalink
Add HttpOnly flag to Set-Cookie #200
Browse files Browse the repository at this point in the history
  • Loading branch information
ikus060 committed Jun 16, 2022
1 parent 8a6bd45 commit 128ab8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions rdiffweb/controller/tests/test_page_login.py
Expand Up @@ -34,6 +34,14 @@ def test_getpage(self):
self.assertStatus('303 See Other')
self.assertHeaderItemValue('Location', self.baseurl + '/login/?redirect=%2F')

def test_cookie_http_only(self):
# Given a request made to rdiffweb
# When receiving the response
self.getPage('/')
# Then the header contains Set-Cookie with HttpOnly
cookie = self.assertHeader('Set-Cookie')
self.assertIn('HttpOnly', cookie)

def test_getpage_with_plaintext(self):
"""
Requesting plain text without being authenticated should show the login form.
Expand Down
1 change: 1 addition & 0 deletions rdiffweb/rdw_app.py
Expand Up @@ -195,6 +195,7 @@ def __init__(self, cfg):
'tools.sessions.debug': cfg.debug,
'tools.sessions.storage_class': session_storage_class,
'tools.sessions.storage_path': self._session_dir,
'tools.sessions.httponly': True,
'tools.ratelimit.debug': cfg.debug,
'tools.ratelimit.delay': 60,
'tools.ratelimit.anonymous_limit': cfg.rate_limit,
Expand Down

0 comments on commit 128ab8f

Please sign in to comment.