File: jupyter_temporary_config.py

package info (click to toggle)
jupyter-server 1.23.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,296 kB
  • sloc: python: 16,373; makefile: 175; javascript: 112
file content (14 lines) | stat: -rw-r--r-- 474 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
from jupyter_server.auth import Authorizer


class TemporaryServerPersonality(Authorizer):
    """Authorizer that prevents modifying files via the contents service"""

    def is_authorized(self, handler, user, action, resource):
        """Allow everything but write on contents"""
        if action == "write" and resource == "contents":
            return False
        return True


c.ServerApp.authorizer_class = TemporaryServerPersonality  # type:ignore[name-defined]