File: jupyter_temporary_config.py

package info (click to toggle)
jupyter-server 2.15.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,068 kB
  • sloc: python: 21,064; makefile: 186; sh: 25; javascript: 14
file content (16 lines) | stat: -rw-r--r-- 522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Nbclassic temporary server auth example."""

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]