2019-10-28 13:44:46 +00:00
|
|
|
"""api v2 urls"""
|
2019-10-28 16:40:57 +00:00
|
|
|
from django.conf.urls import url
|
|
|
|
from django.urls import path
|
|
|
|
from drf_yasg import openapi
|
|
|
|
from drf_yasg.views import get_schema_view
|
2019-10-28 13:27:43 +00:00
|
|
|
from rest_framework import routers
|
2019-10-28 16:40:57 +00:00
|
|
|
from structlog import get_logger
|
2019-10-28 13:27:43 +00:00
|
|
|
|
2019-10-28 16:40:57 +00:00
|
|
|
from passbook.api.permissions import CustomObjectPermissions
|
2020-02-28 10:48:55 +00:00
|
|
|
from passbook.audit.api import EventViewSet
|
2019-10-28 13:27:43 +00:00
|
|
|
from passbook.core.api.applications import ApplicationViewSet
|
|
|
|
from passbook.core.api.groups import GroupViewSet
|
2020-05-23 22:57:25 +00:00
|
|
|
from passbook.core.api.messages import MessagesViewSet
|
2019-10-28 16:55:36 +00:00
|
|
|
from passbook.core.api.propertymappings import PropertyMappingViewSet
|
2020-05-16 14:02:42 +00:00
|
|
|
from passbook.core.api.providers import ProviderViewSet
|
|
|
|
from passbook.core.api.sources import SourceViewSet
|
2019-10-28 13:27:43 +00:00
|
|
|
from passbook.core.api.users import UserViewSet
|
2020-05-08 17:46:39 +00:00
|
|
|
from passbook.flows.api import FlowStageBindingViewSet, FlowViewSet, StageViewSet
|
2019-10-28 16:40:57 +00:00
|
|
|
from passbook.lib.utils.reflection import get_apps
|
2020-05-23 22:57:25 +00:00
|
|
|
from passbook.policies.api import PolicyBindingViewSet, PolicyViewSet
|
2020-05-16 16:07:00 +00:00
|
|
|
from passbook.policies.dummy.api import DummyPolicyViewSet
|
2019-10-28 16:40:57 +00:00
|
|
|
from passbook.policies.expiry.api import PasswordExpiryPolicyViewSet
|
2020-02-19 08:49:57 +00:00
|
|
|
from passbook.policies.expression.api import ExpressionPolicyViewSet
|
2019-10-28 16:40:57 +00:00
|
|
|
from passbook.policies.hibp.api import HaveIBeenPwendPolicyViewSet
|
|
|
|
from passbook.policies.password.api import PasswordPolicyViewSet
|
|
|
|
from passbook.policies.reputation.api import ReputationPolicyViewSet
|
2020-05-16 14:02:42 +00:00
|
|
|
from passbook.providers.app_gw.api import ApplicationGatewayProviderViewSet
|
|
|
|
from passbook.providers.oauth.api import OAuth2ProviderViewSet
|
|
|
|
from passbook.providers.oidc.api import OpenIDProviderViewSet
|
|
|
|
from passbook.providers.saml.api import SAMLPropertyMappingViewSet, SAMLProviderViewSet
|
|
|
|
from passbook.sources.ldap.api import LDAPPropertyMappingViewSet, LDAPSourceViewSet
|
|
|
|
from passbook.sources.oauth.api import OAuthSourceViewSet
|
2020-06-24 20:28:40 +00:00
|
|
|
from passbook.sources.saml.api import SAMLSourceViewSet
|
2020-05-08 17:46:39 +00:00
|
|
|
from passbook.stages.captcha.api import CaptchaStageViewSet
|
2020-06-29 22:19:06 +00:00
|
|
|
from passbook.stages.consent.api import ConsentStageViewSet
|
2020-06-30 08:23:39 +00:00
|
|
|
from passbook.stages.dummy.api import DummyStageViewSet
|
2020-05-08 17:46:39 +00:00
|
|
|
from passbook.stages.email.api import EmailStageViewSet
|
2020-05-09 21:19:36 +00:00
|
|
|
from passbook.stages.identification.api import IdentificationStageViewSet
|
2020-05-11 19:58:02 +00:00
|
|
|
from passbook.stages.invitation.api import InvitationStageViewSet, InvitationViewSet
|
2020-05-08 17:46:39 +00:00
|
|
|
from passbook.stages.otp.api import OTPStageViewSet
|
|
|
|
from passbook.stages.password.api import PasswordStageViewSet
|
2020-05-10 14:20:17 +00:00
|
|
|
from passbook.stages.prompt.api import PromptStageViewSet, PromptViewSet
|
2020-05-13 21:20:07 +00:00
|
|
|
from passbook.stages.user_delete.api import UserDeleteStageViewSet
|
2020-05-10 14:20:44 +00:00
|
|
|
from passbook.stages.user_login.api import UserLoginStageViewSet
|
2020-05-10 23:12:14 +00:00
|
|
|
from passbook.stages.user_logout.api import UserLogoutStageViewSet
|
2020-05-10 21:38:15 +00:00
|
|
|
from passbook.stages.user_write.api import UserWriteStageViewSet
|
2019-10-28 13:27:43 +00:00
|
|
|
|
2019-10-28 16:40:57 +00:00
|
|
|
LOGGER = get_logger()
|
2019-10-28 13:27:43 +00:00
|
|
|
router = routers.DefaultRouter()
|
2019-10-28 16:40:57 +00:00
|
|
|
|
|
|
|
for _passbook_app in get_apps():
|
2019-12-31 11:51:16 +00:00
|
|
|
if hasattr(_passbook_app, "api_mountpoint"):
|
2019-10-28 16:40:57 +00:00
|
|
|
for prefix, viewset in _passbook_app.api_mountpoint:
|
|
|
|
router.register(prefix, viewset)
|
|
|
|
LOGGER.debug("Mounted API URLs", app_name=_passbook_app.name)
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
router.register("core/applications", ApplicationViewSet)
|
|
|
|
router.register("core/groups", GroupViewSet)
|
|
|
|
router.register("core/users", UserViewSet)
|
2020-05-23 22:57:25 +00:00
|
|
|
router.register("core/messages", MessagesViewSet, basename="messages")
|
2020-05-09 21:19:36 +00:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
router.register("audit/events", EventViewSet)
|
2020-05-09 21:19:36 +00:00
|
|
|
|
2020-05-16 14:02:42 +00:00
|
|
|
router.register("sources/all", SourceViewSet)
|
|
|
|
router.register("sources/ldap", LDAPSourceViewSet)
|
2020-06-24 20:28:40 +00:00
|
|
|
router.register("sources/saml", SAMLSourceViewSet)
|
2020-05-16 14:02:42 +00:00
|
|
|
router.register("sources/oauth", OAuthSourceViewSet)
|
2020-05-09 21:19:36 +00:00
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
router.register("policies/all", PolicyViewSet)
|
2020-05-14 11:51:05 +00:00
|
|
|
router.register("policies/bindings", PolicyBindingViewSet)
|
2020-05-10 15:02:01 +00:00
|
|
|
router.register("policies/expression", ExpressionPolicyViewSet)
|
2019-12-31 11:51:16 +00:00
|
|
|
router.register("policies/haveibeenpwned", HaveIBeenPwendPolicyViewSet)
|
|
|
|
router.register("policies/password", PasswordPolicyViewSet)
|
2020-05-10 15:02:01 +00:00
|
|
|
router.register("policies/passwordexpiry", PasswordExpiryPolicyViewSet)
|
2019-12-31 11:51:16 +00:00
|
|
|
router.register("policies/reputation", ReputationPolicyViewSet)
|
2020-05-09 21:19:36 +00:00
|
|
|
|
2020-05-16 14:02:42 +00:00
|
|
|
router.register("providers/all", ProviderViewSet)
|
|
|
|
router.register("providers/applicationgateway", ApplicationGatewayProviderViewSet)
|
|
|
|
router.register("providers/oauth", OAuth2ProviderViewSet)
|
|
|
|
router.register("providers/openid", OpenIDProviderViewSet)
|
|
|
|
router.register("providers/saml", SAMLProviderViewSet)
|
|
|
|
|
2019-12-31 11:51:16 +00:00
|
|
|
router.register("propertymappings/all", PropertyMappingViewSet)
|
|
|
|
router.register("propertymappings/ldap", LDAPPropertyMappingViewSet)
|
|
|
|
router.register("propertymappings/saml", SAMLPropertyMappingViewSet)
|
2020-05-09 21:19:36 +00:00
|
|
|
|
2020-05-08 17:46:39 +00:00
|
|
|
router.register("stages/all", StageViewSet)
|
|
|
|
router.register("stages/captcha", CaptchaStageViewSet)
|
2020-06-29 22:19:06 +00:00
|
|
|
router.register("stages/consent", ConsentStageViewSet)
|
2020-05-08 17:46:39 +00:00
|
|
|
router.register("stages/email", EmailStageViewSet)
|
2020-05-10 15:02:01 +00:00
|
|
|
router.register("stages/identification", IdentificationStageViewSet)
|
2020-05-11 19:58:02 +00:00
|
|
|
router.register("stages/invitation", InvitationStageViewSet)
|
|
|
|
router.register("stages/invitation/invitations", InvitationViewSet)
|
2020-05-08 17:46:39 +00:00
|
|
|
router.register("stages/otp", OTPStageViewSet)
|
|
|
|
router.register("stages/password", PasswordStageViewSet)
|
2020-05-13 09:57:10 +00:00
|
|
|
router.register("stages/prompt/stages", PromptStageViewSet)
|
2020-05-10 14:20:17 +00:00
|
|
|
router.register("stages/prompt/prompts", PromptViewSet)
|
2020-05-13 21:20:07 +00:00
|
|
|
router.register("stages/user_delete", UserDeleteStageViewSet)
|
2020-05-10 15:02:01 +00:00
|
|
|
router.register("stages/user_login", UserLoginStageViewSet)
|
2020-05-10 23:12:14 +00:00
|
|
|
router.register("stages/user_logout", UserLogoutStageViewSet)
|
|
|
|
router.register("stages/user_write", UserWriteStageViewSet)
|
2020-05-09 21:19:36 +00:00
|
|
|
|
2020-05-13 09:57:10 +00:00
|
|
|
router.register("flows/instances", FlowViewSet)
|
2020-05-08 17:46:39 +00:00
|
|
|
router.register("flows/bindings", FlowStageBindingViewSet)
|
2019-10-28 16:40:57 +00:00
|
|
|
|
2020-05-16 16:07:00 +00:00
|
|
|
router.register("stages/dummy", DummyStageViewSet)
|
|
|
|
router.register("policies/dummy", DummyPolicyViewSet)
|
2020-05-10 00:14:55 +00:00
|
|
|
|
2019-10-28 16:40:57 +00:00
|
|
|
info = openapi.Info(
|
|
|
|
title="passbook API",
|
2019-12-31 11:51:16 +00:00
|
|
|
default_version="v2",
|
2019-10-28 16:40:57 +00:00
|
|
|
contact=openapi.Contact(email="hello@beryju.org"),
|
|
|
|
license=openapi.License(name="MIT License"),
|
|
|
|
)
|
|
|
|
SchemaView = get_schema_view(
|
2019-12-31 11:51:16 +00:00
|
|
|
info, public=True, permission_classes=(CustomObjectPermissions,),
|
2019-10-28 16:40:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
urlpatterns = [
|
2019-12-31 11:51:16 +00:00
|
|
|
url(
|
|
|
|
r"^swagger(?P<format>\.json|\.yaml)$",
|
|
|
|
SchemaView.without_ui(cache_timeout=0),
|
|
|
|
name="schema-json",
|
|
|
|
),
|
|
|
|
path(
|
|
|
|
"swagger/",
|
|
|
|
SchemaView.with_ui("swagger", cache_timeout=0),
|
|
|
|
name="schema-swagger-ui",
|
|
|
|
),
|
|
|
|
path("redoc/", SchemaView.with_ui("redoc", cache_timeout=0), name="schema-redoc"),
|
2019-10-28 16:40:57 +00:00
|
|
|
] + router.urls
|