rodauth-tools 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +93 -0
- data/.gitlint +9 -0
- data/.markdownlint-cli2.jsonc +26 -0
- data/.pre-commit-config.yaml +46 -0
- data/.rubocop.yml +18 -0
- data/.rubocop_todo.yml +243 -0
- data/CHANGELOG.md +81 -0
- data/CLAUDE.md +262 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/CONTRIBUTING.md +111 -0
- data/Gemfile +35 -0
- data/Gemfile.lock +356 -0
- data/LICENSE.txt +21 -0
- data/README.md +339 -0
- data/Rakefile +8 -0
- data/lib/rodauth/features/external_identity.rb +946 -0
- data/lib/rodauth/features/hmac_secret_guard.rb +119 -0
- data/lib/rodauth/features/jwt_secret_guard.rb +120 -0
- data/lib/rodauth/features/table_guard.rb +937 -0
- data/lib/rodauth/sequel_generator.rb +531 -0
- data/lib/rodauth/table_inspector.rb +124 -0
- data/lib/rodauth/template_inspector.rb +134 -0
- data/lib/rodauth/tools/console_helpers.rb +158 -0
- data/lib/rodauth/tools/migration/sequel/account_expiration.erb +9 -0
- data/lib/rodauth/tools/migration/sequel/active_sessions.erb +10 -0
- data/lib/rodauth/tools/migration/sequel/audit_logging.erb +12 -0
- data/lib/rodauth/tools/migration/sequel/base.erb +41 -0
- data/lib/rodauth/tools/migration/sequel/disallow_password_reuse.erb +8 -0
- data/lib/rodauth/tools/migration/sequel/email_auth.erb +17 -0
- data/lib/rodauth/tools/migration/sequel/jwt_refresh.erb +18 -0
- data/lib/rodauth/tools/migration/sequel/lockout.erb +21 -0
- data/lib/rodauth/tools/migration/sequel/otp.erb +9 -0
- data/lib/rodauth/tools/migration/sequel/otp_unlock.erb +8 -0
- data/lib/rodauth/tools/migration/sequel/password_expiration.erb +7 -0
- data/lib/rodauth/tools/migration/sequel/recovery_codes.erb +8 -0
- data/lib/rodauth/tools/migration/sequel/remember.erb +16 -0
- data/lib/rodauth/tools/migration/sequel/reset_password.erb +17 -0
- data/lib/rodauth/tools/migration/sequel/single_session.erb +7 -0
- data/lib/rodauth/tools/migration/sequel/sms_codes.erb +10 -0
- data/lib/rodauth/tools/migration/sequel/verify_account.erb +9 -0
- data/lib/rodauth/tools/migration/sequel/verify_login_change.erb +17 -0
- data/lib/rodauth/tools/migration/sequel/webauthn.erb +15 -0
- data/lib/rodauth/tools/migration.rb +188 -0
- data/lib/rodauth/tools/version.rb +9 -0
- data/lib/rodauth/tools.rb +29 -0
- data/package-lock.json +500 -0
- data/package.json +11 -0
- data/rodauth-tools.gemspec +40 -0
- metadata +136 -0
data/CLAUDE.md
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## Project Purpose
|
|
6
|
+
|
|
7
|
+
Framework-agnostic utilities for Rodauth authentication:
|
|
8
|
+
|
|
9
|
+
1. **External Rodauth Features** - `table_guard` for database validation, `external_identity` for external service IDs, `hmac_secret_guard` for HMAC secret validation, `jwt_secret_guard` for JWT secret validation
|
|
10
|
+
2. **Sequel Migration Generator** - Generate migrations for 19 Rodauth features
|
|
11
|
+
|
|
12
|
+
**Not a framework adapter.** For Rails integration, use rodauth-rails. This project demonstrates Rodauth's extensibility and provides reference implementations.
|
|
13
|
+
|
|
14
|
+
**Status:** Experimental learning project. Not published to RubyGems.
|
|
15
|
+
|
|
16
|
+
**Recent Refactoring (2025-10):** Namespace changed from `Rodauth::Rack::Generators::Migration` to `Rodauth::Tools::Migration`. This reflects the project's evolution away from being a Rack adapter toward being a collection of framework-agnostic utilities. The migration generator is now deprecated in favor of the `table_guard` feature with `sequel_mode`.
|
|
17
|
+
|
|
18
|
+
## Development Commands
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Run all tests
|
|
22
|
+
bundle exec rspec
|
|
23
|
+
|
|
24
|
+
# Interactive console with helpers
|
|
25
|
+
bin/console
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Architecture Overview
|
|
29
|
+
|
|
30
|
+
### Core Components
|
|
31
|
+
|
|
32
|
+
**lib/rodauth/features/table_guard.rb** - External Rodauth feature
|
|
33
|
+
|
|
34
|
+
- Uses `Rodauth::Feature.define(:table_guard, :TableGuard)` pattern
|
|
35
|
+
- Validates database tables exist for enabled features at `post_configure` time
|
|
36
|
+
- Provides introspection methods: `missing_tables`, `table_status`, `list_all_required_tables`
|
|
37
|
+
- Configurable modes: `:warn`, `:error`, `:silent`, or custom block handler
|
|
38
|
+
- Demonstrates proper feature lifecycle hooks and configuration DSL
|
|
39
|
+
|
|
40
|
+
**lib/rodauth/features/hmac_secret_guard.rb** - External Rodauth feature
|
|
41
|
+
|
|
42
|
+
- Uses `Rodauth::Feature.define(:hmac_secret_guard, :HmacSecretGuard)` pattern
|
|
43
|
+
- Automatically loads HMAC secret from environment variable (defaults to `HMAC_SECRET`)
|
|
44
|
+
- Validates secret is configured at application startup via `post_configure` hook
|
|
45
|
+
- Production mode: Raises `ConfigurationError` if secret missing
|
|
46
|
+
- Development mode: Logs warning and uses configurable fallback secret
|
|
47
|
+
- Deletes secret from ENV after loading for security
|
|
48
|
+
- Provides `production?` and `validate_secrets!` public methods
|
|
49
|
+
|
|
50
|
+
**lib/rodauth/features/jwt_secret_guard.rb** - External Rodauth feature
|
|
51
|
+
|
|
52
|
+
- Uses `Rodauth::Feature.define(:jwt_secret_guard, :JwtSecretGuard)` pattern
|
|
53
|
+
- Automatically loads JWT secret from environment variable (defaults to `JWT_SECRET`)
|
|
54
|
+
- Validates secret is configured at application startup via `post_configure` hook
|
|
55
|
+
- Production mode: Raises `ConfigurationError` if secret missing
|
|
56
|
+
- Development mode: Logs warning and uses configurable fallback secret
|
|
57
|
+
- Deletes secret from ENV after loading for security
|
|
58
|
+
- Provides `production?` and `validate_secrets!` public methods
|
|
59
|
+
- Defines `jwt_secret` configuration method for standalone use
|
|
60
|
+
|
|
61
|
+
**lib/rodauth/tools/migration.rb** - Sequel migration generator
|
|
62
|
+
|
|
63
|
+
- Generates database migrations for 19 Rodauth features
|
|
64
|
+
- Uses ERB templates in `lib/rodauth/tools/migration/sequel/`
|
|
65
|
+
- Provides `generate()` for migration content and `migration_name()` for filename
|
|
66
|
+
- Uses dry-inflector gem for robust table name pluralization
|
|
67
|
+
- Mock database adapter pattern when no real DB connection provided
|
|
68
|
+
- Deprecated in favor of table_guard feature with sequel_mode
|
|
69
|
+
|
|
70
|
+
### How Rodauth Features Work
|
|
71
|
+
|
|
72
|
+
Rodauth features are modules that mix into `Rodauth::Auth` instances:
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
Feature.define(:feature_name, :FeatureName) do
|
|
76
|
+
# Configuration methods (overridable by users)
|
|
77
|
+
auth_value_method :setting_name, 'default_value'
|
|
78
|
+
|
|
79
|
+
# Public methods (overridable by users)
|
|
80
|
+
auth_methods :public_method
|
|
81
|
+
|
|
82
|
+
# Private methods (not overridable)
|
|
83
|
+
auth_private_methods :internal_helper
|
|
84
|
+
|
|
85
|
+
# Lifecycle hook - runs after configuration
|
|
86
|
+
def post_configure
|
|
87
|
+
super if defined?(super)
|
|
88
|
+
# Initialization code
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Key Pattern:** Methods defined in features become part of the Rodauth instance. Users override them in configuration blocks:
|
|
94
|
+
|
|
95
|
+
```ruby
|
|
96
|
+
plugin :rodauth do
|
|
97
|
+
enable :feature_name
|
|
98
|
+
|
|
99
|
+
setting_name 'custom_value' # Override auth_value_method
|
|
100
|
+
|
|
101
|
+
public_method do # Override auth_methods
|
|
102
|
+
# Custom implementation
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Table Guard Implementation Details
|
|
108
|
+
|
|
109
|
+
**Logger Suppression:** The `table_exists?` method temporarily suppresses Sequel's logger during table existence checks. This prevents confusing ERROR logs from Sequel when checking non-existent tables (Sequel's `table_exists?` attempts a SELECT and logs the exception before catching it).
|
|
110
|
+
|
|
111
|
+
**Configuration Storage:** Uses instance variables set by `auth_value_method`:
|
|
112
|
+
|
|
113
|
+
- Block configs stored as Procs in `@table_guard_mode`
|
|
114
|
+
- Symbol configs stored directly as `:warn`, `:error`, `:silent`
|
|
115
|
+
|
|
116
|
+
**Check Strategy:**
|
|
117
|
+
|
|
118
|
+
1. `should_check_tables?` examines `@table_guard_mode` to decide if checking is needed
|
|
119
|
+
2. Returns `true` if mode is a Proc (block), enabling custom handlers
|
|
120
|
+
3. Returns `true` if mode is `:warn` or `:error`, `false` for `:silent`
|
|
121
|
+
|
|
122
|
+
**Execution Flow:**
|
|
123
|
+
|
|
124
|
+
1. `post_configure` hook calls `check_required_tables!` if `should_check_tables?` returns true
|
|
125
|
+
2. `check_required_tables!` gets missing tables via `missing_tables`
|
|
126
|
+
3. For symbol modes (`:warn`, `:error`), handles directly
|
|
127
|
+
4. For block modes, calls block with missing tables, handles return value (`:error`, `:continue`, String)
|
|
128
|
+
|
|
129
|
+
**Introspection Methods:**
|
|
130
|
+
|
|
131
|
+
- `all_table_methods` - Finds all methods ending in `_table` using Ruby reflection
|
|
132
|
+
- `missing_tables` - Checks each table method against `db.table_exists?`
|
|
133
|
+
- `table_status` - Returns array of hashes with method, table name, and existence status
|
|
134
|
+
|
|
135
|
+
### Migration Generator Architecture
|
|
136
|
+
|
|
137
|
+
**Note:** The Migration class is deprecated. For new code, use the `table_guard` feature with `sequel_mode` instead.
|
|
138
|
+
|
|
139
|
+
**Template System:**
|
|
140
|
+
|
|
141
|
+
- Each feature has ERB template in `lib/rodauth/tools/migration/sequel/`
|
|
142
|
+
- Templates use binding from Migration instance for variables like `table_prefix`
|
|
143
|
+
- `generate()` loads, evaluates, and concatenates all feature templates
|
|
144
|
+
|
|
145
|
+
**Pluralization:**
|
|
146
|
+
|
|
147
|
+
- Uses `dry-inflector` gem for intelligent pluralization (e.g., "status" → "statuses")
|
|
148
|
+
- Helper method `pluralize(str)` available in templates via ERB binding
|
|
149
|
+
- Removed Rails/ActiveRecord dependencies (68 lines of cruft eliminated)
|
|
150
|
+
|
|
151
|
+
**Database Adapter Pattern:**
|
|
152
|
+
|
|
153
|
+
- `MockSequelDatabase` simulates database when no real connection provided
|
|
154
|
+
- Allows template generation without active database
|
|
155
|
+
- Real `Sequel::Database` object can be passed for actual migrations
|
|
156
|
+
- Supports PostgreSQL, MySQL, and SQLite database types
|
|
157
|
+
|
|
158
|
+
### Hidden Tables Architecture
|
|
159
|
+
|
|
160
|
+
**Problem:** Some tables are created in ERB templates without corresponding `*_table` methods in Rodauth features.
|
|
161
|
+
|
|
162
|
+
**Example from base.erb:**
|
|
163
|
+
|
|
164
|
+
```ruby
|
|
165
|
+
# base.erb creates THREE tables:
|
|
166
|
+
create_table(:account_statuses) # NO METHOD - Hidden!
|
|
167
|
+
create_table(:account_password_hashes) # NO METHOD - Hidden!
|
|
168
|
+
create_table(:accounts) # Has accounts_table method ✓
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
**Why This Happens:**
|
|
172
|
+
|
|
173
|
+
- `account_statuses` - Lookup table for status values (Unverified=1, Verified=2, Closed=3). No method because users configure status IDs directly via `account_open_status_value`, etc.
|
|
174
|
+
- `account_password_hashes` - Separate table for security. Method is `account_password_hash_table` (singular), but ERB uses pluralized form based on `table_prefix`.
|
|
175
|
+
|
|
176
|
+
#### Solution: TemplateInspector Module
|
|
177
|
+
|
|
178
|
+
`lib/rodauth/template_inspector.rb` extracts table names directly from ERB templates by:
|
|
179
|
+
|
|
180
|
+
1. Creating minimal binding context with `table_prefix`, `pluralize`, and mock `db`
|
|
181
|
+
2. Evaluating ERB templates to render actual Ruby code
|
|
182
|
+
3. Parsing rendered code for `create_table()` calls using regex
|
|
183
|
+
4. Returning complete list of tables, including hidden ones
|
|
184
|
+
|
|
185
|
+
**Usage:**
|
|
186
|
+
|
|
187
|
+
```ruby
|
|
188
|
+
# Extract all tables for a feature
|
|
189
|
+
tables = TemplateInspector.extract_tables_from_template(
|
|
190
|
+
:base,
|
|
191
|
+
table_prefix: 'account'
|
|
192
|
+
)
|
|
193
|
+
# => [:account_statuses, :account_password_hashes, :accounts]
|
|
194
|
+
|
|
195
|
+
# Get tables for multiple features
|
|
196
|
+
all_tables = TemplateInspector.all_tables_for_features(
|
|
197
|
+
[:base, :verify_account, :lockout],
|
|
198
|
+
table_prefix: 'account'
|
|
199
|
+
)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**Impact on DROP Operations:**
|
|
203
|
+
|
|
204
|
+
Before TemplateInspector, `generate_drop_statements` only dropped dynamically discovered tables, missing hidden ones. Now it extracts the complete table list from ERB templates, ensuring all tables are properly dropped in correct dependency order.
|
|
205
|
+
|
|
206
|
+
**Key Insight:** ERB templates are the single source of truth for table schemas. By extracting information FROM templates instead of duplicating it in Ruby constants, we maintain consistency and eliminate hardcoded mappings.
|
|
207
|
+
|
|
208
|
+
## Testing Patterns
|
|
209
|
+
|
|
210
|
+
**RSpec Structure:**
|
|
211
|
+
|
|
212
|
+
- `spec/spec_helper.rb` - Minimal configuration, loads `rodauth/rack`
|
|
213
|
+
- Feature specs test both behavior and configuration
|
|
214
|
+
- Migration generator specs verify template output and configuration
|
|
215
|
+
|
|
216
|
+
**Console Helpers:**
|
|
217
|
+
|
|
218
|
+
- `setup_test_db` - Creates in-memory SQLite database with tables
|
|
219
|
+
- `create_app(db, features: [...])` - Creates Roda app with Rodauth configured
|
|
220
|
+
- Useful for interactive testing of table_guard and migration generator
|
|
221
|
+
|
|
222
|
+
## Documentation Reference
|
|
223
|
+
|
|
224
|
+
**docs/rodauth-features-api.md** - Complete reference for feature development DSL methods
|
|
225
|
+
|
|
226
|
+
**docs/rodauth-internals.rdoc** - Object model explanation:
|
|
227
|
+
|
|
228
|
+
- `Rodauth::Auth` - Authentication class (where features mix in)
|
|
229
|
+
- `Rodauth::Configuration` - Configuration DSL class
|
|
230
|
+
- `Rodauth::Feature` - Module subclass for feature definitions
|
|
231
|
+
- `Rodauth::FeatureConfiguration` - Configuration module for features
|
|
232
|
+
|
|
233
|
+
**docs/rodauth-mail.md** - Email/SMTP configuration patterns
|
|
234
|
+
|
|
235
|
+
**DEVELOPMENT.md** - Architectural decisions, standard Rack integration pattern
|
|
236
|
+
|
|
237
|
+
## Integration Pattern
|
|
238
|
+
|
|
239
|
+
Rodauth integrates with any Rack app via Roda middleware (NOT via this library):
|
|
240
|
+
|
|
241
|
+
```ruby
|
|
242
|
+
# Create Roda app with Rodauth
|
|
243
|
+
class RodauthApp < Roda
|
|
244
|
+
plugin :middleware
|
|
245
|
+
plugin :rodauth do
|
|
246
|
+
enable :login, :logout
|
|
247
|
+
enable :table_guard # ← Feature from this library
|
|
248
|
+
db DB
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
route do |r|
|
|
252
|
+
r.rodauth
|
|
253
|
+
env['rodauth'] = rodauth
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
# Mount as Rack middleware
|
|
258
|
+
use RodauthApp
|
|
259
|
+
run MyApp
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Access in your app: `request.env['rodauth']` provides all authentication methods.
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
- Demonstrating empathy and kindness toward other people
|
|
21
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
- Giving and gracefully accepting constructive feedback
|
|
23
|
+
- Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
- Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
- The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
- Public or private harassment
|
|
34
|
+
- Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Contributing to rodauth-tools
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to rodauth-tools!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
1. Fork and clone the repository:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/YOUR_USERNAME/rodauth-tools.git
|
|
11
|
+
cd rodauth-tools
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
2. Install dependencies:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
bundle install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
3. Install pre-commit hooks:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Install pre-commit (if not already installed)
|
|
24
|
+
pip install pre-commit
|
|
25
|
+
# or
|
|
26
|
+
brew install pre-commit
|
|
27
|
+
|
|
28
|
+
# Install the git hook scripts
|
|
29
|
+
pre-commit install
|
|
30
|
+
pre-commit install --hook-type commit-msg
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
4. Run tests:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
bundle exec rspec
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Pre-commit Hooks
|
|
40
|
+
|
|
41
|
+
This project uses pre-commit to ensure code quality. The hooks will run automatically on `git commit`.
|
|
42
|
+
|
|
43
|
+
To manually run all hooks on all files:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pre-commit run --all-files
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
To skip hooks (not recommended):
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git commit --no-verify
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Configured Hooks
|
|
56
|
+
|
|
57
|
+
- **File checks**: Trailing whitespace, end-of-file, large files, merge conflicts
|
|
58
|
+
- **RuboCop**: Ruby style and linting (auto-corrects when possible)
|
|
59
|
+
- **Bundler Audit**: Security vulnerability checks
|
|
60
|
+
- **Markdown linting**: Ensures consistent Markdown formatting
|
|
61
|
+
- **Commit message**: Enforces conventional commit format
|
|
62
|
+
|
|
63
|
+
## Code Style
|
|
64
|
+
|
|
65
|
+
We use RuboCop for Ruby code style. Configuration is in `.rubocop.yml`.
|
|
66
|
+
|
|
67
|
+
Key conventions:
|
|
68
|
+
|
|
69
|
+
- Ruby 3.2+ syntax
|
|
70
|
+
- Double quotes for strings
|
|
71
|
+
- 2-space indentation
|
|
72
|
+
|
|
73
|
+
## Commit Messages
|
|
74
|
+
|
|
75
|
+
Follow conventional commits format:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
type(scope): subject
|
|
79
|
+
|
|
80
|
+
body (optional)
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Types: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`
|
|
84
|
+
|
|
85
|
+
Examples:
|
|
86
|
+
|
|
87
|
+
- `feat: add CSRF protection to base adapter`
|
|
88
|
+
- `fix: correct session reset behavior in Rails adapter`
|
|
89
|
+
- `docs: update installation instructions`
|
|
90
|
+
|
|
91
|
+
## Running Tests
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Run all tests
|
|
95
|
+
bundle exec rspec
|
|
96
|
+
|
|
97
|
+
# Run with coverage
|
|
98
|
+
COVERAGE=true bundle exec rspec
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Pull Request Process
|
|
102
|
+
|
|
103
|
+
1. Create a feature branch from `main`
|
|
104
|
+
2. Make your changes with clear, conventional commits
|
|
105
|
+
3. Ensure all tests pass and pre-commit hooks succeed
|
|
106
|
+
4. Update documentation as needed
|
|
107
|
+
5. Submit a pull request with a clear description of changes
|
|
108
|
+
|
|
109
|
+
## Questions?
|
|
110
|
+
|
|
111
|
+
Feel free to open an issue for discussion before starting major work.
|
data/Gemfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Gemfile
|
|
2
|
+
#
|
|
3
|
+
# frozen_string_literal: true
|
|
4
|
+
|
|
5
|
+
source 'https://rubygems.org'
|
|
6
|
+
|
|
7
|
+
gemspec
|
|
8
|
+
|
|
9
|
+
gem 'dry-inflector'
|
|
10
|
+
gem 'irb'
|
|
11
|
+
gem 'rake', '~> 13.3'
|
|
12
|
+
|
|
13
|
+
group :development do
|
|
14
|
+
gem 'bundler-audit'
|
|
15
|
+
gem 'rspec', '~> 3.0'
|
|
16
|
+
gem 'rubocop', '~> 1.81'
|
|
17
|
+
gem 'rubocop-rake'
|
|
18
|
+
gem 'rubocop-rspec'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
group :test do
|
|
22
|
+
gem 'bcrypt', '~> 3.1'
|
|
23
|
+
gem 'capybara'
|
|
24
|
+
gem 'jwt', '~> 3.1'
|
|
25
|
+
gem 'rack-test', '~> 2.1'
|
|
26
|
+
gem 'rails', '>= 6.0'
|
|
27
|
+
gem 'rotp'
|
|
28
|
+
gem 'rqrcode'
|
|
29
|
+
gem 'sequel-activerecord_connection', '~> 2.0'
|
|
30
|
+
gem 'sqlite3', '~> 2.8'
|
|
31
|
+
gem 'tilt', '~> 2.4'
|
|
32
|
+
gem 'tryouts', '~> 3.0'
|
|
33
|
+
gem 'warning'
|
|
34
|
+
gem 'webauthn' unless RUBY_ENGINE == 'jruby'
|
|
35
|
+
end
|