Skip to content
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
2 changes: 0 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ disable_warnings=
omit =
venv/*
cylc/uiserver/tests/*
cylc/uiserver/websockets/*
cylc/uiserver/jupyter*_config.py
parallel = True
plugins=
Expand Down Expand Up @@ -61,7 +60,6 @@ ignore_errors = False
omit =
venv/*
cylc/uiserver/tests/*
cylc/uiserver/websockets/*
cylc/uiserver/jupyter*_config.py
precision=2
show_missing=False
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
fail-fast: false
matrix:
os: ['ubuntu-latest']
python-version: ['3.8', '3.9']
python-version: ['3', '3.8', '3.9']
include:
- os: 'macos-latest'
python-version: '3.8' # oldest supported
Expand Down
1 change: 1 addition & 0 deletions changes.d/672.feat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Major version upgrade for graphene/graphql-core dependencies. Removed the graphene-tornado and graphql-ws dependencies which had blocked Python 3.10 adoption.
17 changes: 8 additions & 9 deletions cylc/uiserver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@
Union,
)

from cylc.flow.network.graphql import (
CylcGraphQLBackend,
IgnoreFieldMiddleware,
)
from cylc.flow.profiler import Profiler
from jupyter_server.extension.application import ExtensionApp
from packaging.version import Version
from tornado import ioloop
Expand All @@ -92,6 +87,10 @@
)
from traitlets.config.loader import LazyConfigValue

from cylc.flow.network.graphql import (
CylcExecutionContext, IgnoreFieldMiddleware
)
from cylc.flow.profiler import Profiler
from cylc.uiserver import __file__ as uis_pkg
from cylc.uiserver.authorise import (
Authorization,
Expand All @@ -112,7 +111,7 @@
)
from cylc.uiserver.resolvers import Resolvers
from cylc.uiserver.schema import schema
from cylc.uiserver.websockets.tornado import TornadoSubscriptionServer
from cylc.uiserver.graphql.tornado_ws import TornadoSubscriptionServer
from cylc.uiserver.workflows_mgr import WorkflowsManager


Expand Down Expand Up @@ -513,11 +512,11 @@ def initialize_handlers(self):
{
'schema': schema,
'resolvers': self.resolvers,
'backend': CylcGraphQLBackend(),
'middleware': [
AuthorizationMiddleware,
IgnoreFieldMiddleware
],
'execution_context_class': CylcExecutionContext,
'auth': self.authobj,
}
),
Expand All @@ -527,11 +526,11 @@ def initialize_handlers(self):
{
'schema': schema,
'resolvers': self.resolvers,
'backend': CylcGraphQLBackend(),
'middleware': [
AuthorizationMiddleware,
IgnoreFieldMiddleware
],
'execution_context_class': CylcExecutionContext,
'batch': True,
'auth': self.authobj,
}
Expand Down Expand Up @@ -571,11 +570,11 @@ def initialize_handlers(self):
def set_sub_server(self):
self.subscription_server = TornadoSubscriptionServer(
schema,
backend=CylcGraphQLBackend(),
middleware=[
IgnoreFieldMiddleware,
AuthorizationMiddleware,
],
execution_context_class=CylcExecutionContext,
auth=self.authobj,
)

Expand Down
25 changes: 14 additions & 11 deletions cylc/uiserver/authorise.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from functools import lru_cache
from getpass import getuser
import grp
from inspect import iscoroutinefunction
import os
from typing import List, Optional, Union, Set, Tuple

import graphene
from graphql.pyutils import is_awaitable
from jupyter_server.auth import Authorizer
from tornado import web

Expand Down Expand Up @@ -508,10 +508,15 @@

def resolve(self, next_, root, info, **args):
current_user = info.context["current_user"]
# We won't be re-checking auth for return variables
if len(info.path) > 1:
# The resolving starts at the top of the path, so only the first
# entry is guarded, and any subsequent fields do not need to be
# checked.
if len(info.path.as_list()) > 1:
return next_(root, info, **args)
op_name = self.get_op_name(info.field_name, info.operation.operation)
op_name = self.get_op_name(
info.field_name,
info.operation.operation.value
)
# It shouldn't get here but worth checking for zero trust
if not op_name:
self.auth_failed(
Expand All @@ -527,12 +532,7 @@
authorised = False
if not authorised:
self.auth_failed(current_user, op_name, http_code=403)
if (
info.operation.operation in Authorization.ASYNC_OPS
or iscoroutinefunction(next_)
):
return self.async_resolve(next_, root, info, **args)
return next_(root, info, **args)
return self.async_resolve(next_, root, info, **args)

def auth_failed(
self,
Expand Down Expand Up @@ -588,7 +588,10 @@

async def async_resolve(self, next_, root, info, **args):
"""Return awaited coroutine"""
return await next_(root, info, **args)
result = next_(root, info, **args)
if is_awaitable(result):
return await result
return result

Check warning on line 594 in cylc/uiserver/authorise.py

View check run for this annotation

Codecov / codecov/patch

cylc/uiserver/authorise.py#L594

Added line #L594 was not covered by tests


def get_groups(username: str) -> Tuple[List[str], List[str]]:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

"""Websockets and subscriptions related code."""
"""GraphQL, Websockets and subscriptions related code."""

from typing import (
Awaitable,
Expand Down
Loading