rodauth_phlex 0.1.0.pre1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +7 -0
  2. data/.rspec +3 -0
  3. data/.standard.yml +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/CODE_OF_CONDUCT.md +132 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +90 -0
  8. data/Rakefile +10 -0
  9. data/lib/rodauth_phlex/component.rb +15 -0
  10. data/lib/rodauth_phlex/components/add_recovery_codes.rb +21 -0
  11. data/lib/rodauth_phlex/components/button.rb +33 -0
  12. data/lib/rodauth_phlex/components/change_login.rb +22 -0
  13. data/lib/rodauth_phlex/components/email_auth_request_form.rb +20 -0
  14. data/lib/rodauth_phlex/components/formatted_field_error.rb +23 -0
  15. data/lib/rodauth_phlex/components/global_logout_field.rb +20 -0
  16. data/lib/rodauth_phlex/components/input_field.rb +74 -0
  17. data/lib/rodauth_phlex/components/login_confirm_field.rb +18 -0
  18. data/lib/rodauth_phlex/components/login_display.rb +19 -0
  19. data/lib/rodauth_phlex/components/login_field.rb +18 -0
  20. data/lib/rodauth_phlex/components/login_form.rb +25 -0
  21. data/lib/rodauth_phlex/components/login_form_footer.rb +20 -0
  22. data/lib/rodauth_phlex/components/login_hidden_field.rb +16 -0
  23. data/lib/rodauth_phlex/components/otp_auth_code_field.rb +22 -0
  24. data/lib/rodauth_phlex/components/password_confirm_field.rb +18 -0
  25. data/lib/rodauth_phlex/components/password_field.rb +18 -0
  26. data/lib/rodauth_phlex/components/recovery_codes.rb +24 -0
  27. data/lib/rodauth_phlex/components/sms_code_field.rb +22 -0
  28. data/lib/rodauth_phlex/components/webauthn_autofill.rb +26 -0
  29. data/lib/rodauth_phlex/components.rb +27 -0
  30. data/lib/rodauth_phlex/email.rb +23 -0
  31. data/lib/rodauth_phlex/emails/email_auth_email.rb +21 -0
  32. data/lib/rodauth_phlex/emails/otp_disabled_email.rb +18 -0
  33. data/lib/rodauth_phlex/emails/otp_locked_out_email.rb +25 -0
  34. data/lib/rodauth_phlex/emails/otp_setup_email.rb +18 -0
  35. data/lib/rodauth_phlex/emails/otp_unlock_failed_email.rb +24 -0
  36. data/lib/rodauth_phlex/emails/otp_unlocked_email.rb +18 -0
  37. data/lib/rodauth_phlex/emails/password_changed_email.rb +18 -0
  38. data/lib/rodauth_phlex/emails/reset_password_email.rb +21 -0
  39. data/lib/rodauth_phlex/emails/reset_password_notify_email.rb +21 -0
  40. data/lib/rodauth_phlex/emails/unlock_account_email.rb +21 -0
  41. data/lib/rodauth_phlex/emails/verify_account_email.rb +20 -0
  42. data/lib/rodauth_phlex/emails/verify_login_change_email.rb +25 -0
  43. data/lib/rodauth_phlex/emails/webauthn_authenticator_added_email.rb +19 -0
  44. data/lib/rodauth_phlex/emails/webauthn_authenticator_removed_email.rb +19 -0
  45. data/lib/rodauth_phlex/emails.rb +22 -0
  46. data/lib/rodauth_phlex/feature.rb +71 -0
  47. data/lib/rodauth_phlex/version.rb +5 -0
  48. data/lib/rodauth_phlex/view.rb +17 -0
  49. data/lib/rodauth_phlex/views/change_password.rb +25 -0
  50. data/lib/rodauth_phlex/views/close_account.rb +20 -0
  51. data/lib/rodauth_phlex/views/confirm_password.rb +20 -0
  52. data/lib/rodauth_phlex/views/create_account.rb +23 -0
  53. data/lib/rodauth_phlex/views/email_auth.rb +19 -0
  54. data/lib/rodauth_phlex/views/login.rb +17 -0
  55. data/lib/rodauth_phlex/views/logout.rb +19 -0
  56. data/lib/rodauth_phlex/views/multi_phase_login.rb +17 -0
  57. data/lib/rodauth_phlex/views/otp_auth.rb +21 -0
  58. data/lib/rodauth_phlex/views/otp_disable.rb +20 -0
  59. data/lib/rodauth_phlex/views/otp_setup.rb +39 -0
  60. data/lib/rodauth_phlex/views/otp_unlock.rb +24 -0
  61. data/lib/rodauth_phlex/views/otp_unlock_not_available.rb +23 -0
  62. data/lib/rodauth_phlex/views/recovery_auth.rb +23 -0
  63. data/lib/rodauth_phlex/views/remember.rb +33 -0
  64. data/lib/rodauth_phlex/views/reset_password.rb +21 -0
  65. data/lib/rodauth_phlex/views/reset_password_request.rb +25 -0
  66. data/lib/rodauth_phlex/views/sms_auth.rb +20 -0
  67. data/lib/rodauth_phlex/views/sms_confirm.rb +20 -0
  68. data/lib/rodauth_phlex/views/sms_disable.rb +20 -0
  69. data/lib/rodauth_phlex/views/sms_request.rb +19 -0
  70. data/lib/rodauth_phlex/views/sms_setup.rb +30 -0
  71. data/lib/rodauth_phlex/views/two_factor_auth.rb +19 -0
  72. data/lib/rodauth_phlex/views/two_factor_disable.rb +20 -0
  73. data/lib/rodauth_phlex/views/two_factor_manage.rb +28 -0
  74. data/lib/rodauth_phlex/views/unlock_account.rb +21 -0
  75. data/lib/rodauth_phlex/views/unlock_account_request.rb +21 -0
  76. data/lib/rodauth_phlex/views/verify_account.rb +21 -0
  77. data/lib/rodauth_phlex/views/verify_account_resend.rb +25 -0
  78. data/lib/rodauth_phlex/views/verify_login_change.rb +19 -0
  79. data/lib/rodauth_phlex/views/webauthn_auth.rb +27 -0
  80. data/lib/rodauth_phlex/views/webauthn_remove.rb +33 -0
  81. data/lib/rodauth_phlex/views/webauthn_setup.rb +28 -0
  82. data/lib/rodauth_phlex/views.rb +39 -0
  83. data/lib/rodauth_phlex.rb +13 -0
  84. metadata +162 -0
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RodauthPhlex::Views
4
+ # This is a Phlex version of the Rodauth template:
5
+ # https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/verify-login-change.str
6
+ #
7
+ # Copyright (c) 2024 Robert Schulze
8
+ # Copyright (c) 2015-2023 Jeremy Evans
9
+ # MIT License
10
+ class VerifyLoginChange < Rodauth::View
11
+ def view_template
12
+ form(method: "post", class: "rodauth", role: "form", id: "verify-login-change-form") do
13
+ safe_html rodauth.verify_login_change_additional_form_tags
14
+ safe_html rodauth.csrf_tag
15
+ Button(rodauth, rodauth.verify_login_change_button)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RodauthPhlex::Views
4
+ # This is a Phlex version of the Rodauth template:
5
+ # https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/webauthn-auth.str
6
+ #
7
+ # Copyright (c) 2024 Robert Schulze
8
+ # Copyright (c) 2015-2023 Jeremy Evans
9
+ # MIT License
10
+ class WebauthnAuth < Rodauth::View
11
+ def view_template
12
+ cred = rodauth.webauthn_credential_options_for_get
13
+
14
+ form(method: "post", action: rodauth.webauthn_auth_form_path, class: "rodauth", role: "form", id: "webauthn-auth-form", data: {credential_options: cred.as_json.to_json}) do
15
+ safe_html rodauth.webauthn_auth_additional_form_tags
16
+ safe_html rodauth.csrf_tag(rodauth.webauthn_auth_form_path)
17
+ input(type: "hidden", name: rodauth.webauthn_auth_challenge_param, value: cred.challenge)
18
+ input(type: "hidden", name: rodauth.webauthn_auth_challenge_hmac_param, value: rodauth.compute_hmac(cred.challenge))
19
+ input(class: "rodauth_hidden d-none", aria: {hidden: "true"}, type: "text", name: rodauth.webauthn_auth_param, id: "webauthn-auth", value: "")
20
+ div(id: "webauthn-auth-button") do
21
+ Button(rodauth, rodauth.webauthn_auth_button)
22
+ end
23
+ end
24
+ script(src: "#{rodauth.webauthn_js_host}#{rodauth.webauthn_auth_js_path}")
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RodauthPhlex::Views
4
+ # This is a Phlex version of the Rodauth template:
5
+ # https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/webauthn-remove.str
6
+ #
7
+ # Copyright (c) 2024 Robert Schulze
8
+ # Copyright (c) 2015-2023 Jeremy Evans
9
+ # MIT License
10
+ class WebauthnRemove < Rodauth::View
11
+ def view_template
12
+ form(method: "post", class: "rodauth", role: "form", id: "webauthn-remove-form") do
13
+ safe_html rodauth.webauthn_remove_additional_form_tags
14
+ safe_html rodauth.csrf_tag
15
+ PasswordField(rodauth) if rodauth.two_factor_modifications_require_password?
16
+ fieldset(class: "form-group mb-3") do
17
+ usage = rodauth.account_webauthn_usage
18
+ last_id = usage.keys.last
19
+
20
+ usage.each do |id, last_use|
21
+ last_use = last_use.strftime(rodauth.strftime_format) if last_use.is_a?(Time)
22
+ div(class: "form-check radio") do
23
+ InputField(rodauth, rodauth.webauthn_remove_param, "webauthn-remove-#{id}", type: "radio", class: "form-check-input", value: id, required: false, skip_error_message: true)
24
+ label(class: "rodauth-webauthn-id form-check-label", for: "webauthn-remove-#{id}") { "Last Use: #{last_use}" }
25
+ FormattedFieldError(rodauth, rodauth.webauthn_remove_param) if id == last_id
26
+ end
27
+ end
28
+ end
29
+ Button(rodauth, rodauth.webauthn_remove_button)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RodauthPhlex::Views
4
+ # This is a Phlex version of the Rodauth template:
5
+ # https://github.com/jeremyevans/rodauth/blob/2.37.0/templates/webauthn-setup.str
6
+ #
7
+ # Copyright (c) 2024 Robert Schulze
8
+ # Copyright (c) 2015-2023 Jeremy Evans
9
+ # MIT License
10
+ class WebauthnSetup < Rodauth::View
11
+ def view_template
12
+ cred = rodauth.new_webauthn_credential
13
+ form(method: "post", class: "rodauth", role: "form", id: "webauthn-setup-form", "data-credential-options": cred.as_json.to_json) do
14
+ safe_html rodauth.webauthn_setup_additional_form_tags
15
+ safe_html rodauth.csrf_tag
16
+ input(type: "hidden", name: rodauth.webauthn_setup_challenge_param, value: cred.challenge)
17
+ input(type: "hidden", name: rodauth.webauthn_setup_challenge_hmac_param, value: rodauth.compute_hmac(cred.challenge))
18
+ input(class: "rodauth_hidden d-none", "aria-hidden": "true", type: "text", name: rodauth.webauthn_setup_param, id: "webauthn-setup", value: "")
19
+ PasswordField(rodauth) if rodauth.two_factor_modifications_require_password?
20
+ div(id: "webauthn-remove-button") do
21
+ Button(rodauth, rodauth.webauthn_setup_button)
22
+ end
23
+ end
24
+
25
+ script(src: "#{rodauth.webauthn_js_host}#{rodauth.webauthn_setup_js_path}")
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ module RodauthPhlex
2
+ autoload :View, "rodauth_phlex/view"
3
+
4
+ module Views
5
+ autoload :ChangePassword, "rodauth_phlex/views/change_password"
6
+ autoload :CloseAccount, "rodauth_phlex/views/close_account"
7
+ autoload :ConfirmPassword, "rodauth_phlex/views/confirm_password"
8
+ autoload :CreateAccount, "rodauth_phlex/views/create_account"
9
+ autoload :EmailAuth, "rodauth_phlex/views/email_auth"
10
+ autoload :Login, "rodauth_phlex/views/login"
11
+ autoload :Logout, "rodauth_phlex/views/logout"
12
+ autoload :MultiPhaseLogin, "rodauth_phlex/views/multi_phase_login"
13
+ autoload :OtpAuth, "rodauth_phlex/views/otp_auth"
14
+ autoload :OtpDisable, "rodauth_phlex/views/otp_disable"
15
+ autoload :OtpSetup, "rodauth_phlex/views/otp_setup"
16
+ autoload :OtpUnlock, "rodauth_phlex/views/otp_unlock"
17
+ autoload :OtpUnlockNotAvailable, "rodauth_phlex/views/otp_unlock_not_available"
18
+ autoload :RecoveryAuth, "rodauth_phlex/views/recovery_auth"
19
+ autoload :Remember, "rodauth_phlex/views/remember"
20
+ autoload :ResetPassword, "rodauth_phlex/views/reset_password"
21
+ autoload :ResetPasswordRequest, "rodauth_phlex/views/reset_password_request"
22
+ autoload :SmsAuth, "rodauth_phlex/views/sms_auth"
23
+ autoload :SmsConfirm, "rodauth_phlex/views/sms_confirm"
24
+ autoload :SmsDisable, "rodauth_phlex/views/sms_disable"
25
+ autoload :SmsRequest, "rodauth_phlex/views/sms_request"
26
+ autoload :SmsSetup, "rodauth_phlex/views/sms_setup"
27
+ autoload :TwoFactorAuth, "rodauth_phlex/views/two_factor_auth"
28
+ autoload :TwoFactorDisable, "rodauth_phlex/views/two_factor_disable"
29
+ autoload :TwoFactorManage, "rodauth_phlex/views/two_factor_manage"
30
+ autoload :UnlockAccount, "rodauth_phlex/views/unlock_account"
31
+ autoload :UnlockAccountRequest, "rodauth_phlex/views/unlock_account_request"
32
+ autoload :VerifyAccount, "rodauth_phlex/views/verify_account"
33
+ autoload :VerifyAccountResend, "rodauth_phlex/views/verify_account_resend"
34
+ autoload :VerifyLoginChange, "rodauth_phlex/views/verify_login_change"
35
+ autoload :WebauthnAuth, "rodauth_phlex/views/webauthn_auth"
36
+ autoload :WebauthnRemove, "rodauth_phlex/views/webauthn_remove"
37
+ autoload :WebauthnSetup, "rodauth_phlex/views/webauthn_setup"
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "phlex"
4
+
5
+ module RodauthPhlex
6
+ class Error < StandardError; end
7
+ Undefined = Object.new.freeze
8
+ end
9
+
10
+ require_relative "rodauth_phlex/version"
11
+ require_relative "rodauth_phlex/components"
12
+ require_relative "rodauth_phlex/views"
13
+ require_relative "rodauth_phlex/feature"
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rodauth_phlex
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.pre1
5
+ platform: ruby
6
+ authors:
7
+ - Robert Schulze
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-12-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: phlex
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.0.rc1
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '3'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0.rc1
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '3'
33
+ - !ruby/object:Gem::Dependency
34
+ name: roda-phlex
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: 0.2.0
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 0.2.0
47
+ description: Render Rodauth templates as Phlex views instead of Tilt templates.
48
+ email:
49
+ - robert@dotless.de
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - ".rspec"
55
+ - ".standard.yml"
56
+ - CHANGELOG.md
57
+ - CODE_OF_CONDUCT.md
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - lib/rodauth_phlex.rb
62
+ - lib/rodauth_phlex/component.rb
63
+ - lib/rodauth_phlex/components.rb
64
+ - lib/rodauth_phlex/components/add_recovery_codes.rb
65
+ - lib/rodauth_phlex/components/button.rb
66
+ - lib/rodauth_phlex/components/change_login.rb
67
+ - lib/rodauth_phlex/components/email_auth_request_form.rb
68
+ - lib/rodauth_phlex/components/formatted_field_error.rb
69
+ - lib/rodauth_phlex/components/global_logout_field.rb
70
+ - lib/rodauth_phlex/components/input_field.rb
71
+ - lib/rodauth_phlex/components/login_confirm_field.rb
72
+ - lib/rodauth_phlex/components/login_display.rb
73
+ - lib/rodauth_phlex/components/login_field.rb
74
+ - lib/rodauth_phlex/components/login_form.rb
75
+ - lib/rodauth_phlex/components/login_form_footer.rb
76
+ - lib/rodauth_phlex/components/login_hidden_field.rb
77
+ - lib/rodauth_phlex/components/otp_auth_code_field.rb
78
+ - lib/rodauth_phlex/components/password_confirm_field.rb
79
+ - lib/rodauth_phlex/components/password_field.rb
80
+ - lib/rodauth_phlex/components/recovery_codes.rb
81
+ - lib/rodauth_phlex/components/sms_code_field.rb
82
+ - lib/rodauth_phlex/components/webauthn_autofill.rb
83
+ - lib/rodauth_phlex/email.rb
84
+ - lib/rodauth_phlex/emails.rb
85
+ - lib/rodauth_phlex/emails/email_auth_email.rb
86
+ - lib/rodauth_phlex/emails/otp_disabled_email.rb
87
+ - lib/rodauth_phlex/emails/otp_locked_out_email.rb
88
+ - lib/rodauth_phlex/emails/otp_setup_email.rb
89
+ - lib/rodauth_phlex/emails/otp_unlock_failed_email.rb
90
+ - lib/rodauth_phlex/emails/otp_unlocked_email.rb
91
+ - lib/rodauth_phlex/emails/password_changed_email.rb
92
+ - lib/rodauth_phlex/emails/reset_password_email.rb
93
+ - lib/rodauth_phlex/emails/reset_password_notify_email.rb
94
+ - lib/rodauth_phlex/emails/unlock_account_email.rb
95
+ - lib/rodauth_phlex/emails/verify_account_email.rb
96
+ - lib/rodauth_phlex/emails/verify_login_change_email.rb
97
+ - lib/rodauth_phlex/emails/webauthn_authenticator_added_email.rb
98
+ - lib/rodauth_phlex/emails/webauthn_authenticator_removed_email.rb
99
+ - lib/rodauth_phlex/feature.rb
100
+ - lib/rodauth_phlex/version.rb
101
+ - lib/rodauth_phlex/view.rb
102
+ - lib/rodauth_phlex/views.rb
103
+ - lib/rodauth_phlex/views/change_password.rb
104
+ - lib/rodauth_phlex/views/close_account.rb
105
+ - lib/rodauth_phlex/views/confirm_password.rb
106
+ - lib/rodauth_phlex/views/create_account.rb
107
+ - lib/rodauth_phlex/views/email_auth.rb
108
+ - lib/rodauth_phlex/views/login.rb
109
+ - lib/rodauth_phlex/views/logout.rb
110
+ - lib/rodauth_phlex/views/multi_phase_login.rb
111
+ - lib/rodauth_phlex/views/otp_auth.rb
112
+ - lib/rodauth_phlex/views/otp_disable.rb
113
+ - lib/rodauth_phlex/views/otp_setup.rb
114
+ - lib/rodauth_phlex/views/otp_unlock.rb
115
+ - lib/rodauth_phlex/views/otp_unlock_not_available.rb
116
+ - lib/rodauth_phlex/views/recovery_auth.rb
117
+ - lib/rodauth_phlex/views/remember.rb
118
+ - lib/rodauth_phlex/views/reset_password.rb
119
+ - lib/rodauth_phlex/views/reset_password_request.rb
120
+ - lib/rodauth_phlex/views/sms_auth.rb
121
+ - lib/rodauth_phlex/views/sms_confirm.rb
122
+ - lib/rodauth_phlex/views/sms_disable.rb
123
+ - lib/rodauth_phlex/views/sms_request.rb
124
+ - lib/rodauth_phlex/views/sms_setup.rb
125
+ - lib/rodauth_phlex/views/two_factor_auth.rb
126
+ - lib/rodauth_phlex/views/two_factor_disable.rb
127
+ - lib/rodauth_phlex/views/two_factor_manage.rb
128
+ - lib/rodauth_phlex/views/unlock_account.rb
129
+ - lib/rodauth_phlex/views/unlock_account_request.rb
130
+ - lib/rodauth_phlex/views/verify_account.rb
131
+ - lib/rodauth_phlex/views/verify_account_resend.rb
132
+ - lib/rodauth_phlex/views/verify_login_change.rb
133
+ - lib/rodauth_phlex/views/webauthn_auth.rb
134
+ - lib/rodauth_phlex/views/webauthn_remove.rb
135
+ - lib/rodauth_phlex/views/webauthn_setup.rb
136
+ homepage: https://github.com/fnordfish/rodauth_phlex
137
+ licenses:
138
+ - MIT
139
+ metadata:
140
+ homepage_uri: https://github.com/fnordfish/rodauth_phlex
141
+ source_code_uri: https://github.com/fnordfish/rodauth_phlex
142
+ changelog_uri: https://github.com/fnordfish/rodauth_phlex/blob/main/CHANGELOG.md
143
+ post_install_message:
144
+ rdoc_options: []
145
+ require_paths:
146
+ - lib
147
+ required_ruby_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '3.2'
152
+ required_rubygems_version: !ruby/object:Gem::Requirement
153
+ requirements:
154
+ - - ">="
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ requirements: []
158
+ rubygems_version: 3.5.23
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: Rodauth templates as Phlex views.
162
+ test_files: []