File: jupyter_nbclassic_rw_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-- 484 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Nbclassic read/write auth example."""

from jupyter_server.auth import Authorizer


class ReadWriteOnly(Authorizer):
    """Authorizer class that makes Jupyter Server a read/write-only server."""

    def is_authorized(self, handler, user, action, resource):
        """Only allows `read` and `write` operations."""
        if action not in {"read", "write"}:
            return False
        return True


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