summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/controllers/_auth.py
blob: 0015a75e40b58e074a9a93ee33c90364c8792df1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import cherrypy


class ControllerAuthMixin:
    @staticmethod
    def _delete_token_cookie(token):
        cherrypy.response.cookie['token'] = token
        cherrypy.response.cookie['token']['expires'] = 0
        cherrypy.response.cookie['token']['max-age'] = 0

    @staticmethod
    def _set_token_cookie(url_prefix, token):
        cherrypy.response.cookie['token'] = token
        if url_prefix == 'https':
            cherrypy.response.cookie['token']['secure'] = True
        cherrypy.response.cookie['token']['HttpOnly'] = True
        cherrypy.response.cookie['token']['path'] = '/'
        cherrypy.response.cookie['token']['SameSite'] = 'Strict'