File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 7
7
"""
8
8
# Copyright (c) Jupyter Development Team.
9
9
# Distributed under the terms of the Modified BSD License.
10
+ from __future__ import annotations
11
+
12
+ from typing import TYPE_CHECKING
13
+
10
14
from traitlets import Instance
11
15
from traitlets .config import LoggingConfigurable
12
16
13
- from jupyter_server .base .handlers import JupyterHandler
14
-
15
17
from .identity import IdentityProvider , User
16
18
19
+ if TYPE_CHECKING :
20
+ from jupyter_server .base .handlers import JupyterHandler
21
+
17
22
18
23
class Authorizer (LoggingConfigurable ):
19
24
"""Base class for authorizing access to resources
Original file line number Diff line number Diff line change 28
28
import jupyter_server
29
29
from jupyter_server ._sysinfo import get_sys_info
30
30
from jupyter_server ._tz import utcnow
31
+ from jupyter_server .auth import authorized
31
32
from jupyter_server .i18n import combine_translations
32
33
from jupyter_server .services .security import csp_report_uri
33
34
from jupyter_server .utils import (
@@ -813,18 +814,22 @@ async def prepare(self):
813
814
class AuthenticatedFileHandler (JupyterHandler , web .StaticFileHandler ):
814
815
"""static files should only be accessible when logged in"""
815
816
817
+ auth_resource = "contents"
818
+
816
819
@property
817
820
def content_security_policy (self ):
818
821
# In case we're serving HTML/SVG, confine any Javascript to a unique
819
822
# origin so it can't interact with the Jupyter server.
820
823
return super ().content_security_policy + "; sandbox allow-scripts"
821
824
822
825
@web .authenticated
826
+ @authorized
823
827
def head (self , path ):
824
828
self .check_xsrf_cookie ()
825
829
return super ().head (path )
826
830
827
831
@web .authenticated
832
+ @authorized
828
833
def get (self , path ):
829
834
if os .path .splitext (path )[1 ] == ".ipynb" or self .get_argument ("download" , None ):
830
835
name = path .rsplit ("/" , 1 )[- 1 ]
You can’t perform that action at this time.
0 commit comments