make oauth client trully optional (#84)

Same old song, after migraiton to packages some optional modules are
being imported globally which lead to making hard dependency
This commit is contained in:
Evgenii Alekseev 2023-01-25 15:25:42 +02:00
parent f4abd83568
commit e368396653
9 changed files with 12 additions and 12 deletions

View File

@ -18,6 +18,3 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from ahriman.core.auth.auth import Auth from ahriman.core.auth.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth

View File

@ -78,10 +78,10 @@ class Auth(LazyLogging):
""" """
provider = AuthSettings.from_option(configuration.get("auth", "target", fallback="disabled")) provider = AuthSettings.from_option(configuration.get("auth", "target", fallback="disabled"))
if provider == AuthSettings.Configuration: if provider == AuthSettings.Configuration:
from ahriman.core.auth import Mapping from ahriman.core.auth.mapping import Mapping
return Mapping(configuration, database) return Mapping(configuration, database)
if provider == AuthSettings.OAuth: if provider == AuthSettings.OAuth:
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
return OAuth(configuration, database) return OAuth(configuration, database)
return cls(configuration) return cls(configuration)

View File

@ -21,7 +21,7 @@ import aioauth_client
from typing import Optional, Type from typing import Optional, Type
from ahriman.core.auth import Mapping from ahriman.core.auth.mapping import Mapping
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.core.exceptions import OptionError from ahriman.core.exceptions import OptionError

View File

@ -53,7 +53,7 @@ class LoginView(BaseView):
Examples: Examples:
This request must not be used directly. This request must not be used directly.
""" """
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
oauth_provider = self.validator oauth_provider = self.validator
if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway if not isinstance(oauth_provider, OAuth): # there is actually property, but mypy does not like it anyway

View File

@ -1,6 +1,7 @@
import pytest import pytest
from ahriman.core.auth import Mapping, OAuth from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite

View File

@ -1,4 +1,6 @@
from ahriman.core.auth import Auth, Mapping, OAuth from ahriman.core.auth import Auth
from ahriman.core.auth.mapping import Mapping
from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.models.user import User from ahriman.models.user import User

View File

@ -1,6 +1,6 @@
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
from ahriman.core.auth import Mapping from ahriman.core.auth.mapping import Mapping
from ahriman.models.user import User from ahriman.models.user import User
from ahriman.models.user_access import UserAccess from ahriman.models.user_access import UserAccess

View File

@ -3,7 +3,7 @@ import pytest
from pytest_mock import MockerFixture from pytest_mock import MockerFixture
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
from ahriman.core.exceptions import OptionError from ahriman.core.exceptions import OptionError

View File

@ -9,7 +9,7 @@ from unittest.mock import MagicMock
import ahriman.core.auth.helpers import ahriman.core.auth.helpers
from ahriman.core.auth import OAuth from ahriman.core.auth.oauth import OAuth
from ahriman.core.configuration import Configuration from ahriman.core.configuration import Configuration
from ahriman.core.database import SQLite from ahriman.core.database import SQLite
from ahriman.core.repository import Repository from ahriman.core.repository import Repository