Skip to content

Commit

Permalink
Remove cyclic dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
psrok1 committed Sep 24, 2024
1 parent aee7d65 commit 98e6ab1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions mwdb/core/oauth/provider.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import hashlib
from typing import Iterator
from typing import TYPE_CHECKING, Iterator

from authlib.oidc.core import UserInfo
from marshmallow import ValidationError
from sqlalchemy import exists

from mwdb.model import Group, User, db
from mwdb.schema.user import UserLoginSchemaBase

from .client import OpenIDClient

if TYPE_CHECKING:
from mwdb.model import Group, User


class OpenIDProvider:
"""
Expand Down Expand Up @@ -55,6 +57,8 @@ def create_provider_group(self) -> "Group":
"""
Creates a Group model object for a new OpenID provider
"""
from mwdb.model import Group

group_name = self.get_group_name()
return Group(name=group_name, immutable=True, workspace=False)

Expand Down Expand Up @@ -94,6 +98,8 @@ def create_user(self, sub: bytes, userinfo: UserInfo) -> "User":
"""
Creates a User model object for a new OpenID identity user
"""
from mwdb.model import Group, User, db

for username in self.iter_user_name_variants(sub, userinfo):
try:
UserLoginSchemaBase().load({"login": username})
Expand Down

0 comments on commit 98e6ab1

Please sign in to comment.