version_1.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. from django.urls import include, path, re_path
  2. from rest_framework.routers import SimpleRouter
  3. from desecapi import views
  4. tokens_router = SimpleRouter()
  5. tokens_router.register(r"", views.TokenViewSet, basename="token")
  6. tokendomainpolicies_router = SimpleRouter()
  7. tokendomainpolicies_router.register(
  8. r"", views.TokenDomainPolicyViewSet, basename="token_domain_policies"
  9. )
  10. totp_router = SimpleRouter()
  11. totp_router.register(r"", views.TOTPViewSet, basename="totp")
  12. auth_urls = [
  13. # User management
  14. path("", views.AccountCreateView.as_view(), name="register"),
  15. path("account/", views.AccountView.as_view(), name="account"),
  16. path("account/delete/", views.AccountDeleteView.as_view(), name="account-delete"),
  17. path(
  18. "account/change-email/",
  19. views.AccountChangeEmailView.as_view(),
  20. name="account-change-email",
  21. ),
  22. path(
  23. "account/reset-password/",
  24. views.AccountResetPasswordView.as_view(),
  25. name="account-reset-password",
  26. ),
  27. path("login/", views.AccountLoginView.as_view(), name="login"),
  28. path("logout/", views.AccountLogoutView.as_view(), name="logout"),
  29. # Token management
  30. path("tokens/", include(tokens_router.urls)),
  31. path(
  32. "tokens/<uuid:token_id>/policies/",
  33. views.TokenPoliciesRoot.as_view(),
  34. name="token-policies-root",
  35. ),
  36. path(
  37. "tokens/<uuid:token_id>/policies/domain/",
  38. include(tokendomainpolicies_router.urls),
  39. ),
  40. path("totp/", include(totp_router.urls)),
  41. ]
  42. domains_router = SimpleRouter()
  43. domains_router.register(r"", views.DomainViewSet, basename="domain")
  44. api_urls = [
  45. # API home
  46. path("", views.Root.as_view(), name="root"),
  47. # Domain and RRSet management
  48. path("domains/", include(domains_router.urls)),
  49. path("domains/<name>/rrsets/", views.RRsetList.as_view(), name="rrsets"),
  50. path(
  51. "domains/<name>/rrsets/.../<type>/",
  52. views.RRsetDetail.as_view(),
  53. kwargs={"subname": ""},
  54. ),
  55. re_path(
  56. r"^domains/(?P<name>[^/]+)/rrsets/(?P<subname>[^/]*)\.\.\./(?P<type>[^/]+)/$",
  57. views.RRsetDetail.as_view(),
  58. name="rrset",
  59. ),
  60. path(
  61. "domains/<name>/rrsets/@/<type>/",
  62. views.RRsetDetail.as_view(),
  63. kwargs={"subname": ""},
  64. ),
  65. re_path(
  66. r"^domains/(?P<name>[^/]+)/rrsets/(?P<subname>[^/]*)@/(?P<type>[^/]+)/$",
  67. views.RRsetDetail.as_view(),
  68. name="rrset@",
  69. ),
  70. path("domains/<name>/rrsets/<subname>/<type>/", views.RRsetDetail.as_view()),
  71. # DynDNS update
  72. path("dyndns/update", views.DynDNS12UpdateView.as_view(), name="dyndns12update"),
  73. # Serials
  74. path("serials/", views.SerialListView.as_view(), name="serial"),
  75. # Donation
  76. path("donation/", views.DonationList.as_view(), name="donation"),
  77. # Authenticated Actions
  78. path(
  79. "v/activate-account/<code>/",
  80. views.AuthenticatedActivateUserActionView.as_view(),
  81. name="confirm-activate-account",
  82. ),
  83. path(
  84. "v/change-email/<code>/",
  85. views.AuthenticatedChangeEmailUserActionView.as_view(),
  86. name="confirm-change-email",
  87. ),
  88. path(
  89. "v/change-outreach-preference/<code>/",
  90. views.AuthenticatedChangeOutreachPreferenceUserActionView.as_view(),
  91. name="confirm-change-outreach-preference",
  92. ),
  93. path(
  94. "v/confirm-account/<code>/",
  95. views.AuthenticatedConfirmAccountUserActionView.as_view(),
  96. name="confirm-confirm-account",
  97. ),
  98. path(
  99. "v/create-totp/<code>/",
  100. views.AuthenticatedCreateTOTPFactorUserActionView.as_view(),
  101. name="confirm-create-totp",
  102. ),
  103. path(
  104. "v/reset-password/<code>/",
  105. views.AuthenticatedResetPasswordUserActionView.as_view(),
  106. name="confirm-reset-password",
  107. ),
  108. path(
  109. "v/delete-account/<code>/",
  110. views.AuthenticatedDeleteUserActionView.as_view(),
  111. name="confirm-delete-account",
  112. ),
  113. path(
  114. "v/renew-domain/<code>/",
  115. views.AuthenticatedRenewDomainBasicUserActionView.as_view(),
  116. name="confirm-renew-domain",
  117. ),
  118. # CAPTCHA
  119. path("captcha/", views.CaptchaView.as_view(), name="captcha"),
  120. ]
  121. app_name = "desecapi"
  122. urlpatterns = [
  123. path("auth/", include(auth_urls)),
  124. path("", include(api_urls)),
  125. ]