Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a base auth plugin to depend on instead of jupyverse #232

Merged
merged 7 commits into from
Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
- name: Install Dependencies
run: |
pip install -e . --no-deps
pip install -e plugins/auth_base
pip install -e plugins/frontend
pip install -e plugins/jupyterlab
pip install -e plugins/retrolab
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ jobs:

- name: Install jupyverse
run: |
pip install ./plugins/auth_base
pip install ./plugins/frontend
pip install ./plugins/jupyterlab
pip install ./plugins/login
Expand All @@ -53,6 +54,7 @@ jobs:
- name: Check types
run: |
mypy jupyverse
mypy plugins/auth_base/fps_auth_base
mypy plugins/frontend/fps_frontend
mypy plugins/contents/fps_contents
mypy plugins/kernels/fps_kernels
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Created by https://www.toptal.com/developers/gitignore/api/git,linux,macos,python,windows,pycharm,jupyternotebook,vscode
# Edit at https://www.toptal.com/developers/gitignore?templates=git,linux,macos,python,windows,pycharm,jupyternotebook,vscode

.fps_cli_args.toml

### Git ###
# Created by git for backups. To disable backups in Git:
# $ git config --global mergetool.keepBackup false
Expand Down
2 changes: 2 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Then install the needed plugins.

- With the [fps-auth](../plugins/auth/#fps-auth) plugin:
```bash
pip install -e plugins/auth_base
pip install -e plugins/frontend
pip install -e plugins/lab
pip install -e plugins/jupyterlab
Expand All @@ -54,6 +55,7 @@ pip install -e .[test]
```
- With the [fps-auth-fief](../plugins/auth/#fps-auth-fief) plugin:
```bash
pip install -e plugins/auth_base
pip install -e plugins/frontend
pip install -e plugins/lab
pip install -e plugins/jupyterlab
Expand Down
1 change: 1 addition & 0 deletions docs/plugins/auth_base.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`fps-auth-base`
14 changes: 0 additions & 14 deletions jupyverse/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1 @@
import pkg_resources

__version__ = "0.0.41"

auth = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyverse_auth")}

try:
User = auth["User"]
current_user = auth["current_user"]
update_user = auth["update_user"]
websocket_auth = auth["websocket_auth"]
except KeyError:
raise RuntimeError(
"An auth plugin must be installed for Jupyverse to run. For instance: pip install fps-auth"
)
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ nav:
- Plugins:
- 'FPS': plugins/fps.md
- 'auth': plugins/auth.md
- 'fps-auth-base': plugins/auth_base.md
- 'fps-contents': plugins/contents.md
- 'fps-frontend': plugins/frontend.md
- 'fps-lab': plugins/lab.md
Expand Down
59 changes: 59 additions & 0 deletions plugins/auth_base/COPYING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Licensing terms

This project is licensed under the terms of the Modified BSD License
(also known as New or Revised or 3-Clause BSD), as follows:

- Copyright (c) 2021-, Jupyter Development Team

All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

Neither the name of the Jupyter Development Team nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

## About the Jupyter Development Team

The Jupyter Development Team is the set of all contributors to the Jupyter project.
This includes all of the Jupyter subprojects.

The core team that coordinates development on GitHub can be found here:
https://github.com/jupyter/.

## Our Copyright Policy

Jupyter uses a shared copyright model. Each contributor maintains copyright
over their contributions to Jupyter. But, it is important to note that these
contributions are typically only changes to the repositories. Thus, the Jupyter
source code, in its entirety is not the copyright of any single person or
institution. Instead, it is the collective copyright of the entire Jupyter
Development Team. If individual contributors want to maintain a record of what
changes/contributions they have specific copyright on, they should indicate
their copyright in the commit message of the change, when they commit the
change to one of the Jupyter repositories.

With this in mind, the following banner should be used in any source code file
to indicate the copyright and license terms:

# Copyright (c) Jupyter Development Team.
# Distributed under the terms of the Modified BSD License.
1 change: 1 addition & 0 deletions plugins/auth_base/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include *.md
3 changes: 3 additions & 0 deletions plugins/auth_base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# fps-auth-base

An FPS plugin for the authentication API.
15 changes: 15 additions & 0 deletions plugins/auth_base/fps_auth_base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import pkg_resources

__version__ = "0.0.41"

auth = {ep.name: ep.load() for ep in pkg_resources.iter_entry_points(group="jupyverse_auth")}

try:
User = auth["User"]
current_user = auth["current_user"]
update_user = auth["update_user"]
websocket_auth = auth["websocket_auth"]
except KeyError:
raise RuntimeError(
"An auth plugin must be installed, for instance: pip install fps-auth",
)
34 changes: 34 additions & 0 deletions plugins/auth_base/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[build-system]
requires = [ "hatchling",]
build-backend = "hatchling.build"

[project]
name = "fps_auth_base"
description = "An FPS plugin for the authentication API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = ["fps >=0.0.17"]
dynamic = [ "version",]

[[project.authors]]
name = "Jupyter Development Team"
email = "jupyter@googlegroups.com"

[project.readme]
file = "README.md"
content-type = "text/markdown"

[project.license]
text = "BSD 3-Clause License"

[project.urls]
Homepage = "https://jupyter.org"

[tool.check-manifest]
ignore = [ ".*",]

[tool.jupyter-releaser]
skip = [ "check-links",]

[tool.hatch.version]
path = "fps_auth_base/__init__.py"
3 changes: 1 addition & 2 deletions plugins/contents/fps_contents/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
from anyio import open_file
from fastapi import APIRouter, Depends, HTTPException, Response
from fps.hooks import register_router # type: ignore
from fps_auth_base import User, current_user # type: ignore
from starlette.requests import Request # type: ignore

from jupyverse import User, current_user

from .models import Checkpoint, Content, CreateContent, RenameContent, SaveContent

router = APIRouter()
Expand Down
2 changes: 1 addition & 1 deletion plugins/contents/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_contents"
description = "An FPS plugin for the contents API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "anyio", "watchfiles >=0.16.1,<1",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "anyio", "watchfiles >=0.16.1,<1",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
3 changes: 1 addition & 2 deletions plugins/jupyterlab/fps_jupyterlab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fps.hooks import register_router # type: ignore
from fps_auth_base import User, current_user, update_user # type: ignore
from fps_frontend.config import get_frontend_config # type: ignore
from fps_lab.config import get_lab_config # type: ignore
from fps_lab.routes import init_router # type: ignore
from fps_lab.utils import get_federated_extensions # type: ignore
from starlette.requests import Request # type: ignore

from jupyverse import User, current_user, update_user

from .config import get_jlab_config

router = APIRouter()
Expand Down
2 changes: 1 addition & 1 deletion plugins/jupyterlab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_jupyterlab"
description = "An FPS plugin for the JupyterLab API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "fps-frontend", "fps-lab", "jupyterlab >=4.0.0a27",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "fps-frontend", "fps-lab", "jupyterlab >=4.0.0a27",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
3 changes: 1 addition & 2 deletions plugins/kernels/fps_kernels/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
from fastapi import APIRouter, Depends, Response
from fastapi.responses import FileResponse
from fps.hooks import register_router # type: ignore
from fps_auth_base import User, current_user, websocket_auth # type: ignore
from fps_frontend.config import get_frontend_config # type: ignore
from fps_yjs.routes import YDocWebSocketHandler # type: ignore
from starlette.requests import Request # type: ignore

from jupyverse import User, current_user, websocket_auth

from .kernel_driver.driver import KernelDriver # type: ignore
from .kernel_server.server import ( # type: ignore
AcceptedWebSocket,
Expand Down
2 changes: 1 addition & 1 deletion plugins/kernels/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_kernels"
description = "An FPS plugin for the kernels API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "fps-frontend", "fps-yjs", "pyzmq", "websockets", "python-dateutil",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "fps-frontend", "fps-yjs", "pyzmq", "websockets", "python-dateutil",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
2 changes: 1 addition & 1 deletion plugins/lab/fps_lab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
from fastapi import Depends, Response, status
from fastapi.responses import FileResponse, RedirectResponse
from fastapi.staticfiles import StaticFiles
from fps_auth_base import User, current_user, update_user # type: ignore
from fps_frontend.config import get_frontend_config # type: ignore
from starlette.requests import Request # type: ignore

import jupyverse # type: ignore
from jupyverse import User, current_user, update_user

from .utils import get_federated_extensions

Expand Down
2 changes: 1 addition & 1 deletion plugins/lab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_lab"
description = "An FPS plugin for the JupyterLab/RetroLab API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "fps-frontend", "aiofiles", "babel", "json5",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "fps-frontend", "aiofiles", "babel", "json5",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
3 changes: 1 addition & 2 deletions plugins/nbconvert/fps_nbconvert/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from fastapi import APIRouter, Depends
from fastapi.responses import FileResponse
from fps.hooks import register_router # type: ignore

from jupyverse import User, current_user
from fps_auth_base import User, current_user # type: ignore

router = APIRouter()

Expand Down
2 changes: 1 addition & 1 deletion plugins/nbconvert/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_nbconvert"
description = "An FPS plugin for the nbconvert API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "nbconvert",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "nbconvert",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
3 changes: 1 addition & 2 deletions plugins/retrolab/fps_retrolab/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@
from fastapi.responses import HTMLResponse
from fastapi.staticfiles import StaticFiles
from fps.hooks import register_router # type: ignore
from fps_auth_base import User, current_user # type: ignore
from fps_frontend.config import get_frontend_config # type: ignore
from fps_lab.config import get_lab_config # type: ignore
from fps_lab.routes import init_router # type: ignore
from fps_lab.utils import get_federated_extensions # type: ignore

from jupyverse import User, current_user # type: ignore

router = APIRouter()
prefix_dir, federated_extensions = init_router(router, "retro/tree")
retrolab_dir = Path(retrolab.__file__).parent
Expand Down
2 changes: 1 addition & 1 deletion plugins/retrolab/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_retrolab"
description = "An FPS plugin for the RetroLab API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "fps-frontend", "fps-lab", "retrolab",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "fps-frontend", "fps-lab", "retrolab",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
3 changes: 1 addition & 2 deletions plugins/terminals/fps_terminals/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@

from fastapi import APIRouter, Depends, Response
from fps.hooks import register_router # type: ignore

from jupyverse import User, current_user, websocket_auth
from fps_auth_base import User, current_user, websocket_auth # type: ignore

from .models import Terminal

Expand Down
2 changes: 1 addition & 1 deletion plugins/terminals/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_terminals"
description = "An FPS plugin for the terminals API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "websockets", "pywinpty;platform_system=='Windows'",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "websockets", "pywinpty;platform_system=='Windows'",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
3 changes: 1 addition & 2 deletions plugins/yjs/fps_yjs/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
has_awatch = True
except ImportError:
has_awatch = False
from fps_auth_base import websocket_auth # type: ignore
from jupyter_ydoc import ydocs as YDOCS # type: ignore
from ypy_websocket.websocket_server import WebsocketServer, YRoom # type: ignore
from ypy_websocket.ystore import BaseYStore, SQLiteYStore, YDocNotFound # type: ignore
from ypy_websocket.yutils import YMessageType # type: ignore

from jupyverse import websocket_auth

YFILE = YDOCS["file"]
AWARENESS = 1
RENAME_SESSION = 127
Expand Down
2 changes: 1 addition & 1 deletion plugins/yjs/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "fps_yjs"
description = "An FPS plugin for the Yjs API"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fps >=0.0.8", "fps-contents", "jupyter_ydoc >=0.1.16,<0.2.0", "ypy-websocket >=0.3.2,<0.4.0",]
dependencies = [ "fps >=0.0.8", "fps-auth-base", "fps-contents", "jupyter_ydoc >=0.1.16,<0.2.0", "ypy-websocket >=0.3.2,<0.4.0",]
dynamic = [ "version",]
[[project.authors]]
name = "Jupyter Development Team"
Expand Down
5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ name = "jupyverse"
description = "A set of FPS plugins implementing a Jupyter server"
keywords = [ "jupyter", "server", "fastapi", "pluggy", "plugins",]
requires-python = ">=3.7"
dependencies = [ "fastapi >=0.82.0", "fps >=0.0.19", "fps-uvicorn >=0.0.19", "fps-contents ==0.0.41", "fps-kernels ==0.0.41", "fps-terminals ==0.0.41", "fps-nbconvert ==0.0.41", "fps-yjs ==0.0.41",]
dependencies = [ "fastapi >=0.82.0", "fps >=0.0.19", "fps-uvicorn >=0.0.19", "fps-auth-base ==0.0.41", "fps-contents ==0.0.41", "fps-kernels ==0.0.41", "fps-terminals ==0.0.41", "fps-nbconvert ==0.0.41", "fps-yjs ==0.0.41",]
dynamic = [ "version",]

[[project.authors]]
name = "Jupyter Development Team"
email = "jupyter@googlegroups.com"
Expand Down Expand Up @@ -44,7 +45,7 @@ skip = [ "check-links", "check-manifest",]
max-line-length = 100

[tool.jupyter-releaser.options]
python_packages = [ "plugins/auth:fps-auth", "plugins/auth_fief:fps-auth-fief", "plugins/contents:fps-contents", "plugins/frontend:fps-frontend", "plugins/jupyterlab:fps-jupyterlab", "plugins/kernels:fps-kernels", "plugins/lab:fps-lab", "plugins/nbconvert:fps-nbconvert", "plugins/retrolab:fps-retrolab", "plugins/terminals:fps-terminals", "plugins/yjs:fps-yjs", "plugins/login:fps-login", ".:jupyverse:fps-auth,fps-auth-fief,fps-contents,fps-jupyterlab,fps-kernels,fps-lab,fps-frontend,fps-nbconvert,fps-retrolab,fps-terminals,fps-yjs",]
python_packages = ["plugins/auth_base:fps-auth-base", "plugins/auth:fps-auth", "plugins/auth_fief:fps-auth-fief", "plugins/contents:fps-contents", "plugins/frontend:fps-frontend", "plugins/jupyterlab:fps-jupyterlab", "plugins/kernels:fps-kernels", "plugins/lab:fps-lab", "plugins/nbconvert:fps-nbconvert", "plugins/retrolab:fps-retrolab", "plugins/terminals:fps-terminals", "plugins/yjs:fps-yjs", "plugins/login:fps-login", ".:jupyverse:fps-auth-base,fps-auth,fps-auth-fief,fps-contents,fps-jupyterlab,fps-kernels,fps-lab,fps-frontend,fps-nbconvert,fps-retrolab,fps-terminals,fps-yjs",]

[tool.hatch.version]
path = "jupyverse/__init__.py"
Expand Down