Coverage for app/venv/lib/python3.14/site-packages/weblate/accounts/urls.py: 76%

15 statements  

« prev     ^ index     » next       coverage.py v7.15.2, created at 2026-10-07 07:15 +0000

1# Copyright © Michal Čihař <michal@weblate.org> 

2# 

3# SPDX-License-Identifier: GPL-3.0-or-later 

4 

5import django_otp_webauthn.views 

6from django.conf import settings 

7from django.urls import include, path 

8from django.views.i18n import JavaScriptCatalog 

9 

10import weblate.accounts.views 

11import weblate.auth.views 

12from weblate.utils.urls import register_weblate_converters 

13 

14register_weblate_converters() 

15 

16 

17# Follows copy of social_django.urls with few changes: 

18# - authentication requires POST (issue submitted upstream) 

19# - authentication stores current user (to avoid CSRF on complete) 

20# - removed some configurability (just to avoid additional deps) 

21# - the association_id has to be numeric (patch accepted upstream) 

22social_urls = [ 

23 # user authentication / association 

24 path("login/<slug:backend>/", weblate.accounts.views.social_auth, name="begin"), 

25 # partial pipeline completion 

26 path( 

27 "complete/<slug:backend>/", 

28 weblate.accounts.views.social_complete, 

29 name="complete", 

30 ), 

31 # disconnection 

32 path( 

33 "disconnect/<slug:backend>/", 

34 weblate.accounts.views.social_disconnect, 

35 name="disconnect", 

36 ), 

37 path( 

38 "disconnect/<slug:backend>/<int:association_id>/", 

39 weblate.accounts.views.social_disconnect, 

40 name="disconnect_individual", 

41 ), 

42 # SAML 

43 path("metadata/saml/", weblate.accounts.views.saml_metadata, name="saml-metadata"), 

44] 

45 

46# WebAuthn views, this is modified django_otp_webauth.urls 

47webauthn_urls = [ 

48 path( 

49 "registration/begin/", 

50 django_otp_webauthn.views.BeginCredentialRegistrationView.as_view(), 

51 name="credential-registration-begin", 

52 ), 

53 path( 

54 "registration/complete/", 

55 django_otp_webauthn.views.CompleteCredentialRegistrationView.as_view(), 

56 name="credential-registration-complete", 

57 ), 

58 path( 

59 "authentication/begin/", 

60 weblate.accounts.views.WeblateBeginCredentialAuthenticationView.as_view(), 

61 name="credential-authentication-begin", 

62 ), 

63 path( 

64 "authentication/complete/", 

65 weblate.accounts.views.WeblateCompleteCredentialAuthenticationView.as_view(), 

66 name="credential-authentication-complete", 

67 ), 

68 path( 

69 "jsi18n/", 

70 JavaScriptCatalog.as_view(packages=["django_otp_webauthn"]), 

71 name="js-i18n-catalog", 

72 ), 

73] 

74 

75urlpatterns = [ 

76 path( 

77 "email-sent/", 

78 weblate.accounts.views.EmailSentView.as_view(), 

79 name="email-sent", 

80 ), 

81 path("password/", weblate.accounts.views.password, name="password"), 

82 path("reset-api-key/", weblate.accounts.views.reset_api_key, name="reset-api-key"), 

83 path("reset/", weblate.accounts.views.reset_password, name="password_reset"), 

84 path("logout/", weblate.accounts.views.WeblateLogoutView.as_view(), name="logout"), 

85 path("profile/", weblate.accounts.views.user_profile, name="profile"), 

86 path("userdata/", weblate.accounts.views.userdata, name="userdata"), 

87 path("unsubscribe/", weblate.accounts.views.unsubscribe, name="unsubscribe"), 

88 path("subscribe/", weblate.accounts.views.subscribe, name="subscribe"), 

89 path("watch/<object_path:path>/", weblate.accounts.views.watch, name="watch"), 

90 path("unwatch/<object_path:path>/", weblate.accounts.views.unwatch, name="unwatch"), 

91 path("mute/<object_path:path>/", weblate.accounts.views.mute, name="mute"), 

92 path("remove/", weblate.accounts.views.user_remove, name="remove"), 

93 path("confirm/", weblate.accounts.views.confirm, name="confirm"), 

94 path("login/", weblate.accounts.views.WeblateLoginView.as_view(), name="login"), 

95 path("register/", weblate.accounts.views.register, name="register"), 

96 path("email/", weblate.accounts.views.email_login, name="email_login"), 

97 path( 

98 "invitation/<uuid:pk>/", 

99 weblate.auth.views.InvitationView.as_view(), 

100 name="invitation", 

101 ), 

102 path( 

103 "auth/second-factor/<slug:backend>/", 

104 weblate.accounts.views.SecondFactorLoginView.as_view(), 

105 name="2fa-login", 

106 ), 

107 path( 

108 "auth/tokens/webauthn/<int:pk>/", 

109 weblate.accounts.views.WebAuthnCredentialView.as_view(), 

110 name="webauthn-detail", 

111 ), 

112 path( 

113 "auth/tokens/totp/", 

114 weblate.accounts.views.TOTPView.as_view(), 

115 name="totp", 

116 ), 

117 path( 

118 "auth/tokens/totp/<int:pk>/", 

119 weblate.accounts.views.TOTPDetailView.as_view(), 

120 name="totp-detail", 

121 ), 

122 path( 

123 "auth/tokens/recovery-codes/", 

124 weblate.accounts.views.RecoveryCodesView.as_view(), 

125 name="recovery-codes", 

126 ), 

127 path("", include((social_urls, "social_auth"), namespace="social")), 

128 path( 

129 "auth/webauthn/", 

130 include((webauthn_urls, "django_otp_webauthn"), namespace="otp_webauthn"), 

131 ), 

132] 

133 

134if "simple_sso.sso_server" in settings.INSTALLED_APPS: 134 ↛ 135line 134 didn't jump to line 135 because the condition on line 134 was never true

135 from simple_sso.sso_server.server import Server 

136 

137 server = Server() 

138 urlpatterns.append(path("sso/", include(server.get_urls())))