better_auth 0.1.1
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/.ruby-version +1 -0
- data/.standard.yml +12 -0
- data/.vscode/settings.json +22 -0
- data/AGENTS.md +50 -0
- data/CHANGELOG.md +17 -0
- data/CLAUDE.md +1 -0
- data/CODE_OF_CONDUCT.md +173 -0
- data/CONTRIBUTING.md +187 -0
- data/Gemfile +12 -0
- data/LICENSE.md +20 -0
- data/Makefile +207 -0
- data/README.md +267 -0
- data/Rakefile +25 -0
- data/SECURITY.md +28 -0
- data/docker-compose.yml +63 -0
- data/lib/better_auth/core.rb +7 -0
- data/lib/better_auth/version.rb +5 -0
- data/lib/better_auth.rb +9 -0
- metadata +192 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a2ba3cc27f9b1ebc6cb35de7a95a10351c30f5523de796c82b7c90773d663381
|
|
4
|
+
data.tar.gz: 81b03e1d625d242adc6255806b7651cebee65f59179110aae7df85b7beab426f
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 61a29dc835cd5758628b358153888cc78eb721795cd286e55210c920766129826d08b5bbdf2fe9a049df56b3d6a9d4bd8f33c82b067bde77c812c87738af94e2
|
|
7
|
+
data.tar.gz: 18d543129a8577e9974ce0887db187e837ff2b9175cce97efd33a6afba615f1d34272fb193a0008694c63c998b12740ed6c2490ecb765ad9b24f131be389a250
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.3.10
|
data/.standard.yml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"rubyLsp.enabled": true,
|
|
3
|
+
"rubyLsp.formatter": "standard",
|
|
4
|
+
"rubyLsp.linters": ["standard"],
|
|
5
|
+
"editor.formatOnSave": true,
|
|
6
|
+
"editor.insertSpaces": true,
|
|
7
|
+
"editor.tabSize": 2,
|
|
8
|
+
"files.insertFinalNewline": true,
|
|
9
|
+
"files.trimTrailingWhitespace": true,
|
|
10
|
+
"[ruby]": {
|
|
11
|
+
"editor.defaultFormatter": "Shopify.ruby-lsp",
|
|
12
|
+
"editor.formatOnSave": true,
|
|
13
|
+
"editor.rulers": [120]
|
|
14
|
+
},
|
|
15
|
+
"search.exclude": {
|
|
16
|
+
"**/.bundle": true,
|
|
17
|
+
"**/vendor": true,
|
|
18
|
+
"**/coverage": true,
|
|
19
|
+
"**/doc": true,
|
|
20
|
+
"**/*.gem": true
|
|
21
|
+
}
|
|
22
|
+
}
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# AGENTS.md - Better Auth Core Package
|
|
2
|
+
|
|
3
|
+
**⚠️ CRITICAL: Always read this file when editing files in packages/better_auth/**
|
|
4
|
+
|
|
5
|
+
## What is this package?
|
|
6
|
+
|
|
7
|
+
This is the **core gem** of Better Auth Ruby - a Ruby port of the TypeScript [better-auth](https://github.com/better-auth/better-auth) library. It contains framework-agnostic authentication logic built on Rack.
|
|
8
|
+
|
|
9
|
+
## Upstream Reference
|
|
10
|
+
|
|
11
|
+
**Always check `upstream/` before implementing or modifying features.**
|
|
12
|
+
|
|
13
|
+
The TypeScript implementation in `upstream/packages/better-auth/` is the source of truth. Your workflow should be:
|
|
14
|
+
|
|
15
|
+
1. **Find the feature** in `upstream/packages/better-auth/src/`
|
|
16
|
+
2. **Understand how it works** in TypeScript
|
|
17
|
+
3. **Translate to Ruby** following Ruby/Rails best practices
|
|
18
|
+
4. **Adapt idiomatically** - don't do a literal translation, make it feel native to Ruby
|
|
19
|
+
|
|
20
|
+
Key upstream directories:
|
|
21
|
+
- `upstream/packages/better-auth/src/` - Core auth logic
|
|
22
|
+
- `upstream/packages/better-auth/src/plugins/` - Plugin implementations
|
|
23
|
+
|
|
24
|
+
## Development Commands
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bundle install # Install dependencies
|
|
28
|
+
bundle exec rake test # Run tests (Minitest)
|
|
29
|
+
bundle exec standardrb # Run linter
|
|
30
|
+
bundle exec standardrb --fix # Fix linting issues
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Directory Structure
|
|
34
|
+
|
|
35
|
+
* `lib/better_auth.rb` - Main entry point
|
|
36
|
+
* `lib/better_auth/core/` - Core authentication logic
|
|
37
|
+
* `test/` - Tests (Minitest)
|
|
38
|
+
|
|
39
|
+
## Code Style
|
|
40
|
+
|
|
41
|
+
* StandardRB for linting
|
|
42
|
+
* `frozen_string_literal: true` in all files
|
|
43
|
+
* snake_case for files/methods, CamelCase for classes
|
|
44
|
+
|
|
45
|
+
## After Everything is Done
|
|
46
|
+
|
|
47
|
+
**Unless the user asked for it, DO NOT COMMIT**
|
|
48
|
+
|
|
49
|
+
* Make sure `bundle exec standardrb` passes
|
|
50
|
+
* Make sure `bundle exec rake test` passes
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Initial project setup
|
|
13
|
+
- Basic gem structure
|
|
14
|
+
- StandardRB configuration
|
|
15
|
+
- Minitest for core testing
|
|
16
|
+
- RSpec for Rails adapter testing
|
|
17
|
+
- CI/CD workflows for GitHub Actions
|
data/CLAUDE.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
AGENTS.md
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Contributor Covenant 3.0
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We pledge to make our community welcoming, safe, and equitable for all.
|
|
6
|
+
|
|
7
|
+
We are committed to fostering an environment that respects and promotes the
|
|
8
|
+
dignity, rights, and contributions of all individuals, regardless of
|
|
9
|
+
characteristics including race, ethnicity, caste, color, age, physical
|
|
10
|
+
characteristics, neurodiversity, disability, sex or gender, gender identity or
|
|
11
|
+
expression, sexual orientation, language, philosophy or religion, national or
|
|
12
|
+
social origin, socio-economic position, level of education, or other status.
|
|
13
|
+
The same privileges of participation are extended to everyone who participates
|
|
14
|
+
in good faith and in accordance with this Covenant.
|
|
15
|
+
|
|
16
|
+
## Encouraged Behaviors
|
|
17
|
+
|
|
18
|
+
While acknowledging differences in social norms, we all strive to meet our
|
|
19
|
+
community's expectations for positive behavior.
|
|
20
|
+
We also understand that our words and actions may be interpreted differently
|
|
21
|
+
than we intend based on culture, background, or native language.
|
|
22
|
+
|
|
23
|
+
With these considerations in mind, we agree to behave mindfully toward each
|
|
24
|
+
other and act in ways that center our shared values, including:
|
|
25
|
+
|
|
26
|
+
1. Respecting the **purpose of our community**, our activities, and our ways of
|
|
27
|
+
gathering.
|
|
28
|
+
2. Engaging **kindly and honestly** with others.
|
|
29
|
+
3. Respecting **different viewpoints** and experiences.
|
|
30
|
+
4. **Taking responsibility** for our actions and contributions.
|
|
31
|
+
5. Gracefully giving and accepting **constructive feedback**.
|
|
32
|
+
6. Committing to **repairing harm** when it occurs.
|
|
33
|
+
7. Behaving in other ways that promote and sustain the **well-being of our
|
|
34
|
+
community**.
|
|
35
|
+
|
|
36
|
+
## Restricted Behaviors
|
|
37
|
+
|
|
38
|
+
We agree to restrict the following behaviors in our community.
|
|
39
|
+
Instances, threats, and promotion of these behaviors are violations of this Code
|
|
40
|
+
of Conduct.
|
|
41
|
+
|
|
42
|
+
1. **Harassment.** Violating explicitly expressed boundaries or engaging in
|
|
43
|
+
unnecessary personal attention after any clear request to stop.
|
|
44
|
+
2. **Character attacks.** Making insulting, demeaning, or pejorative comments
|
|
45
|
+
directed at a community member or group of people.
|
|
46
|
+
3. **Stereotyping or discrimination.** Characterizing anyone's personality or
|
|
47
|
+
behavior on the basis of immutable identities or traits.
|
|
48
|
+
4. **Sexualization.** Behaving in a way that would generally be considered
|
|
49
|
+
inappropriately intimate in the context or purpose of the community.
|
|
50
|
+
5. **Violating confidentiality**. Sharing or acting on someone's personal or
|
|
51
|
+
private information without their permission.
|
|
52
|
+
6. **Endangerment.** Causing, encouraging, or threatening violence or other harm
|
|
53
|
+
toward any person or group.
|
|
54
|
+
7. Behaving in other ways that **threaten the well-being** of our community.
|
|
55
|
+
|
|
56
|
+
### Other Restrictions
|
|
57
|
+
|
|
58
|
+
1. **Misleading identity.** Impersonating someone else for any reason, or
|
|
59
|
+
pretending to be someone else to evade enforcement actions.
|
|
60
|
+
2. **Failing to credit sources.** Not properly crediting the sources of content
|
|
61
|
+
you contribute.
|
|
62
|
+
3. **Promotional materials**. Sharing marketing or other commercial content in a
|
|
63
|
+
way that is outside the norms of the community.
|
|
64
|
+
4. **Irresponsible communication.** Failing to responsibly present content which
|
|
65
|
+
includes, links or describes any other restricted behaviors.
|
|
66
|
+
|
|
67
|
+
## Reporting an Issue
|
|
68
|
+
|
|
69
|
+
Tensions can occur between community members even when they are trying their
|
|
70
|
+
best to collaborate.
|
|
71
|
+
|
|
72
|
+
Not every conflict represents a code of conduct violation, and this Code of
|
|
73
|
+
Conduct reinforces encouraged behaviors and norms that can help avoid conflicts
|
|
74
|
+
and minimize harm.
|
|
75
|
+
|
|
76
|
+
When an incident does occur, it is important to report it promptly.
|
|
77
|
+
To report a possible violation, **email [community@better-auth.com](mailto:community@better-auth.com)**
|
|
78
|
+
|
|
79
|
+
Community Moderators take reports of violations seriously and will make every
|
|
80
|
+
effort to respond in a timely manner.
|
|
81
|
+
|
|
82
|
+
They will investigate all reports of code of conduct violations, reviewing
|
|
83
|
+
messages, logs, and recordings, or interviewing witnesses and other
|
|
84
|
+
participants.
|
|
85
|
+
|
|
86
|
+
Community Moderators will keep investigation and enforcement actions as
|
|
87
|
+
transparent as possible while prioritizing safety and confidentiality.
|
|
88
|
+
|
|
89
|
+
In order to honor these values, enforcement actions are carried out in private
|
|
90
|
+
with the involved parties, but communicating to the whole community may be part
|
|
91
|
+
of a mutually agreed upon resolution.
|
|
92
|
+
|
|
93
|
+
## Addressing and Repairing Harm
|
|
94
|
+
|
|
95
|
+
If an investigation by the Community Moderators finds that this Code of Conduct
|
|
96
|
+
has been violated, the following enforcement ladder may be used to determine how
|
|
97
|
+
best to repair harm, based on the incident's impact on the individuals involved
|
|
98
|
+
and the community as a whole.
|
|
99
|
+
Depending on the severity of a violation, lower rungs on the ladder may be
|
|
100
|
+
skipped.
|
|
101
|
+
|
|
102
|
+
1. Warning
|
|
103
|
+
1. Event: A violation involving a single incident or series of incidents.
|
|
104
|
+
2. Consequence: A private, written warning from the Community Moderators.
|
|
105
|
+
3. Repair: Examples of repair include a private written apology,
|
|
106
|
+
acknowledgement of responsibility, and seeking clarification on
|
|
107
|
+
expectations.
|
|
108
|
+
2. Temporarily Limited Activities
|
|
109
|
+
1. Event: A repeated incidence of a violation that previously resulted in a
|
|
110
|
+
warning, or the first incidence of a more serious violation.
|
|
111
|
+
2. Consequence: A private, written warning with a time-limited cooldown
|
|
112
|
+
period designed to underscore the seriousness of the situation and give
|
|
113
|
+
the community members involved time to process the incident.
|
|
114
|
+
The cooldown period may be limited to particular communication channels or
|
|
115
|
+
interactions with particular community members.
|
|
116
|
+
3. Repair: Examples of repair may include making an apology, using the
|
|
117
|
+
cooldown period to reflect on actions and impact, and being thoughtful
|
|
118
|
+
about re-entering community spaces after the period is over.
|
|
119
|
+
3. Temporary Suspension
|
|
120
|
+
1. Event: A pattern of repeated violation which the Community Moderators have
|
|
121
|
+
tried to address with warnings, or a single serious violation.
|
|
122
|
+
2. Consequence: A private written warning with conditions for return from
|
|
123
|
+
suspension.
|
|
124
|
+
In general, temporary suspensions give the person being suspended time to
|
|
125
|
+
reflect upon their behavior and possible corrective actions.
|
|
126
|
+
3. Repair: Examples of repair include respecting the spirit of the
|
|
127
|
+
suspension, meeting the specified conditions for return, and being
|
|
128
|
+
thoughtful about how to reintegrate with the community when the suspension
|
|
129
|
+
is lifted.
|
|
130
|
+
4. Permanent Ban
|
|
131
|
+
1. Event: A pattern of repeated code of conduct violations that other steps
|
|
132
|
+
on the ladder have failed to resolve, or a violation so serious that the
|
|
133
|
+
Community Moderators determine there is no way to keep the community safe
|
|
134
|
+
with this person as a member.
|
|
135
|
+
2. Consequence: Access to all community spaces, tools, and communication
|
|
136
|
+
channels is removed.
|
|
137
|
+
In general, permanent bans should be rarely used, should have strong
|
|
138
|
+
reasoning behind them, and should only be resorted to if working through
|
|
139
|
+
other remedies has failed to change the behavior.
|
|
140
|
+
3. Repair: There is no possible repair in cases of this severity.
|
|
141
|
+
|
|
142
|
+
This enforcement ladder is intended as a guideline.
|
|
143
|
+
It does not limit the ability of Community Managers to use their discretion and
|
|
144
|
+
judgment, in keeping with the best interests of our community.
|
|
145
|
+
|
|
146
|
+
## Scope
|
|
147
|
+
|
|
148
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
149
|
+
an individual is officially representing the community in public or other
|
|
150
|
+
spaces.
|
|
151
|
+
Examples of representing our community include using an official email address,
|
|
152
|
+
posting via an official social media account, or acting as an appointed
|
|
153
|
+
representative at an online or offline event.
|
|
154
|
+
|
|
155
|
+
## Attribution
|
|
156
|
+
|
|
157
|
+
This Code of Conduct is adapted from the Contributor Covenant, version 3.0,
|
|
158
|
+
permanently available at
|
|
159
|
+
[https://www.contributor-covenant.org/version/3/0/](https://www.contributor-covenant.org/version/3/0/).
|
|
160
|
+
|
|
161
|
+
Contributor Covenant is stewarded by the Organization for Ethical Source and
|
|
162
|
+
licensed under CC BY-SA 4.0.
|
|
163
|
+
To view a copy of this license, visit
|
|
164
|
+
[https://creativecommons.org/licenses/by-sa/4.0/](https://creativecommons.org/licenses/by-sa/4.0/)
|
|
165
|
+
|
|
166
|
+
For answers to common questions about Contributor Covenant, see the FAQ at
|
|
167
|
+
[https://www.contributor-covenant.org/faq](https://www.contributor-covenant.org/faq).
|
|
168
|
+
Translations are provided at
|
|
169
|
+
[https://www.contributor-covenant.org/translations](https://www.contributor-covenant.org/translations).
|
|
170
|
+
Additional enforcement and community guideline resources can be found at
|
|
171
|
+
[https://www.contributor-covenant.org/resources](https://www.contributor-covenant.org/resources).
|
|
172
|
+
The enforcement ladder was inspired by the work of
|
|
173
|
+
[Mozilla's code of conduct team](https://github.com/mozilla/inclusion).
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
# Contributing to Better Auth Ruby
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to Better Auth Ruby!
|
|
4
|
+
This guide will help you get started with the contribution process.
|
|
5
|
+
|
|
6
|
+
## Code of Conduct
|
|
7
|
+
|
|
8
|
+
This project and everyone participating in it is governed by our
|
|
9
|
+
[Code of Conduct](/CODE_OF_CONDUCT.md).
|
|
10
|
+
By participating, you are expected to uphold this code.
|
|
11
|
+
|
|
12
|
+
## Project Structure
|
|
13
|
+
|
|
14
|
+
```
|
|
15
|
+
lib/
|
|
16
|
+
better_auth.rb # Main entry point
|
|
17
|
+
better_auth/
|
|
18
|
+
version.rb # Version constant
|
|
19
|
+
core.rb # Core module loader
|
|
20
|
+
core/ # Core authentication logic
|
|
21
|
+
rails.rb # Rails adapter entry
|
|
22
|
+
rails/ # Rails-specific code
|
|
23
|
+
|
|
24
|
+
test/ # Core library tests (Minitest)
|
|
25
|
+
spec/ # Rails adapter tests (RSpec)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Development Guidelines
|
|
29
|
+
|
|
30
|
+
When contributing to Better Auth Ruby:
|
|
31
|
+
|
|
32
|
+
* Keep changes focused. Large PRs are harder to review.
|
|
33
|
+
* Follow Ruby conventions and idioms
|
|
34
|
+
* Ensure all code passes StandardRB linting
|
|
35
|
+
* Write tests for new features
|
|
36
|
+
* Maintain backward compatibility when possible
|
|
37
|
+
|
|
38
|
+
## Getting Started
|
|
39
|
+
|
|
40
|
+
1. Fork the repository to your GitHub account
|
|
41
|
+
|
|
42
|
+
2. Clone your fork locally:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
git clone https://github.com/your-username/better-auth-ruby.git
|
|
46
|
+
cd better-auth-ruby
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
3. Install Ruby (3.2+ required, 3.3 recommended)
|
|
50
|
+
|
|
51
|
+
We recommend using a Ruby version manager like rbenv, rvm, or asdf.
|
|
52
|
+
|
|
53
|
+
4. Install dependencies:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
bundle install
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
5. Run tests to ensure everything is working:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
bundle exec rake ci
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Development Workflow
|
|
66
|
+
|
|
67
|
+
1. Create a new branch for your changes:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
git checkout -b type/description
|
|
71
|
+
# Example: git checkout -b feat/oauth-provider
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Branch type prefixes:
|
|
75
|
+
|
|
76
|
+
* `feat/` - New features
|
|
77
|
+
* `fix/` - Bug fixes
|
|
78
|
+
* `docs/` - Documentation changes
|
|
79
|
+
* `refactor/` - Code refactoring
|
|
80
|
+
* `test/` - Test-related changes
|
|
81
|
+
* `chore/` - Build process or tooling changes
|
|
82
|
+
|
|
83
|
+
2. Make your changes following the code style guidelines
|
|
84
|
+
|
|
85
|
+
3. Run the linter:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
bundle exec standardrb --fix
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
4. Add tests for your changes
|
|
92
|
+
|
|
93
|
+
5. Run the test suite:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
# Run all tests
|
|
97
|
+
bundle exec rake ci
|
|
98
|
+
|
|
99
|
+
# Run only core tests
|
|
100
|
+
bundle exec rake test
|
|
101
|
+
|
|
102
|
+
# Run only Rails adapter tests
|
|
103
|
+
bundle exec rspec
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
6. Commit your changes with a descriptive message:
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
feat(rails): add current_user helper method
|
|
110
|
+
|
|
111
|
+
fix(core): resolve token validation issue
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
7. Push your branch to your fork
|
|
115
|
+
|
|
116
|
+
8. Open a pull request against the **main** branch
|
|
117
|
+
|
|
118
|
+
## Code Style
|
|
119
|
+
|
|
120
|
+
We use [StandardRB](https://github.com/standardrb/standard) for code formatting and linting.
|
|
121
|
+
Before committing, please ensure your code passes:
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
# Check code style
|
|
125
|
+
bundle exec standardrb
|
|
126
|
+
|
|
127
|
+
# Auto-fix issues
|
|
128
|
+
bundle exec standardrb --fix
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Ruby Style Guidelines
|
|
132
|
+
|
|
133
|
+
* Use 2 spaces for indentation
|
|
134
|
+
* Use `snake_case` for methods, variables, and file names
|
|
135
|
+
* Use `CamelCase` for classes and modules
|
|
136
|
+
* Use `SCREAMING_SNAKE_CASE` for constants
|
|
137
|
+
* Add `frozen_string_literal: true` pragma to all Ruby files
|
|
138
|
+
* Prefer single quotes for strings without interpolation
|
|
139
|
+
* Avoid unnecessary Ruby features (unless they improve readability)
|
|
140
|
+
|
|
141
|
+
## Testing Guidelines
|
|
142
|
+
|
|
143
|
+
### Core Library (Minitest)
|
|
144
|
+
|
|
145
|
+
Located in `test/` directory:
|
|
146
|
+
|
|
147
|
+
```ruby
|
|
148
|
+
# test/better_auth/some_feature_test.rb
|
|
149
|
+
require_relative "test_helper"
|
|
150
|
+
|
|
151
|
+
class SomeFeatureTest < Minitest::Test
|
|
152
|
+
def test_something
|
|
153
|
+
assert_equal expected, actual
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
### Rails Adapter (RSpec)
|
|
159
|
+
|
|
160
|
+
Located in `spec/` directory:
|
|
161
|
+
|
|
162
|
+
```ruby
|
|
163
|
+
# spec/better_auth/rails/some_feature_spec.rb
|
|
164
|
+
require "spec_helper"
|
|
165
|
+
|
|
166
|
+
RSpec.describe BetterAuth::Rails::SomeFeature do
|
|
167
|
+
it "does something" do
|
|
168
|
+
expect(subject).to eq expected
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Pull Request Process
|
|
174
|
+
|
|
175
|
+
1. Create a draft pull request early to facilitate discussion
|
|
176
|
+
2. Reference any related issues in your PR description
|
|
177
|
+
3. Ensure all tests pass and the build is successful
|
|
178
|
+
4. Update documentation as needed
|
|
179
|
+
5. Keep your PR focused on a single feature or bug fix
|
|
180
|
+
6. Be responsive to code review feedback
|
|
181
|
+
|
|
182
|
+
## Security Issues
|
|
183
|
+
|
|
184
|
+
For security-related issues, please email [security@better-auth.com](mailto:security@better-auth.com).
|
|
185
|
+
Include a detailed description of the vulnerability and steps to reproduce it.
|
|
186
|
+
All reports will be reviewed and addressed promptly.
|
|
187
|
+
For more information, see our [security documentation](/SECURITY.md).
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
Copyright (c) 2024 - present, Bereket Engida
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
5
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
6
|
+
the Software without restriction, including without limitation the rights to
|
|
7
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
8
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
9
|
+
subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
16
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
18
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
19
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
20
|
+
DEALINGS IN THE SOFTWARE.
|
data/Makefile
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# Better Auth Ruby - Makefile
|
|
2
|
+
# Este archivo te ayuda a ejecutar comandos comunes de desarrollo
|
|
3
|
+
# Cada comando tiene comentarios explicativos para aprender
|
|
4
|
+
|
|
5
|
+
# Variables de color para hacer la salida más legible
|
|
6
|
+
BLUE := \033[36m
|
|
7
|
+
GREEN := \033[32m
|
|
8
|
+
YELLOW := \033[33m
|
|
9
|
+
NC := \033[0m # No Color
|
|
10
|
+
|
|
11
|
+
# =============================================
|
|
12
|
+
# COMANDOS PRINCIPALES DE DESARROLLO
|
|
13
|
+
# =============================================
|
|
14
|
+
|
|
15
|
+
# Instala todas las dependencias del proyecto
|
|
16
|
+
# Equivale a: bundle install
|
|
17
|
+
.PHONY: install
|
|
18
|
+
install:
|
|
19
|
+
@echo "$(BLUE)📦 Instalando dependencias...$(NC)"
|
|
20
|
+
bundle install
|
|
21
|
+
@echo "$(GREEN)✓ Dependencias instaladas$(NC)"
|
|
22
|
+
|
|
23
|
+
# Configuración inicial del proyecto (primer clone)
|
|
24
|
+
# Ejecuta bin/setup que hace bundle install
|
|
25
|
+
.PHONY: setup
|
|
26
|
+
setup:
|
|
27
|
+
@echo "$(BLUE)🔧 Configurando proyecto...$(NC)"
|
|
28
|
+
bin/setup
|
|
29
|
+
@echo "$(GREEN)✓ Proyecto configurado$(NC)"
|
|
30
|
+
|
|
31
|
+
# =============================================
|
|
32
|
+
# COMANDOS DE CALIDAD DE CÓDIGO
|
|
33
|
+
# =============================================
|
|
34
|
+
|
|
35
|
+
# Revisa que el código cumpla con el estilo StandardRB
|
|
36
|
+
# Muestra errores pero NO los corrige automáticamente
|
|
37
|
+
.PHONY: lint
|
|
38
|
+
lint:
|
|
39
|
+
@echo "$(BLUE)🔍 Revisando estilo de código...$(NC)"
|
|
40
|
+
bundle exec standardrb
|
|
41
|
+
@echo "$(GREEN)✓ Código cumple con el estilo$(NC)"
|
|
42
|
+
|
|
43
|
+
# Revisa Y AUTOCORRIGE problemas de estilo con StandardRB
|
|
44
|
+
# Úsalo cuando quieras formatear todo automáticamente
|
|
45
|
+
.PHONY: lint-fix
|
|
46
|
+
lint-fix:
|
|
47
|
+
@echo "$(BLUE)🔧 Corrigiendo estilo de código automáticamente...$(NC)"
|
|
48
|
+
bundle exec standardrb --fix
|
|
49
|
+
@echo "$(GREEN)✓ Código corregido$(NC)"
|
|
50
|
+
|
|
51
|
+
# =============================================
|
|
52
|
+
# COMANDOS DE TESTING
|
|
53
|
+
# =============================================
|
|
54
|
+
|
|
55
|
+
# Ejecuta TODOS los tests (core + rails adapter)
|
|
56
|
+
# Es lo mismo que: bundle exec rake ci
|
|
57
|
+
.PHONY: test
|
|
58
|
+
test:
|
|
59
|
+
@echo "$(BLUE)🧪 Ejecutando todos los tests...$(NC)"
|
|
60
|
+
bundle exec rake test
|
|
61
|
+
@echo "$(GREEN)✓ Tests completados$(NC)"
|
|
62
|
+
|
|
63
|
+
# Ejecuta solo los tests del core (Minitest)
|
|
64
|
+
# Son los tests en el directorio test/
|
|
65
|
+
.PHONY: test-core
|
|
66
|
+
test-core:
|
|
67
|
+
@echo "$(BLUE)🧪 Ejecutando tests del core...$(NC)"
|
|
68
|
+
bundle exec rake test:core
|
|
69
|
+
@echo "$(GREEN)✓ Tests del core completados$(NC)"
|
|
70
|
+
|
|
71
|
+
# Ejecuta solo los tests del adapter Rails (RSpec)
|
|
72
|
+
# Son los tests en el directorio spec/
|
|
73
|
+
.PHONY: test-rails
|
|
74
|
+
test-rails:
|
|
75
|
+
@echo "$(BLUE)🧪 Ejecutando tests del adapter Rails...$(NC)"
|
|
76
|
+
bundle exec rspec
|
|
77
|
+
@echo "$(GREEN)✓ Tests de Rails completados$(NC)"
|
|
78
|
+
|
|
79
|
+
# Ejecuta tests con cobertura de código
|
|
80
|
+
# Genera reporte en coverage/index.html
|
|
81
|
+
.PHONY: test-coverage
|
|
82
|
+
test-coverage:
|
|
83
|
+
@echo "$(BLUE)📊 Ejecutando tests con cobertura...$(NC)"
|
|
84
|
+
COVERAGE=true bundle exec rake test
|
|
85
|
+
@echo "$(GREEN)✓ Reporte de cobertura en coverage/index.html$(NC)"
|
|
86
|
+
|
|
87
|
+
# =============================================
|
|
88
|
+
# COMANDOS DE INTEGRACIÓN CONTINUA (CI)
|
|
89
|
+
# =============================================
|
|
90
|
+
|
|
91
|
+
# Ejecuta TODO el pipeline de CI localmente
|
|
92
|
+
# 1. Lint (StandardRB)
|
|
93
|
+
# 2. Tests (Minitest + RSpec)
|
|
94
|
+
# Esto es lo que corre GitHub Actions en cada PR
|
|
95
|
+
.PHONY: ci
|
|
96
|
+
ci:
|
|
97
|
+
@echo "$(BLUE)🔧 Ejecutando CI completo...$(NC)"
|
|
98
|
+
bundle exec rake ci
|
|
99
|
+
@echo "$(GREEN)✓ CI completado exitosamente$(NC)"
|
|
100
|
+
|
|
101
|
+
# =============================================
|
|
102
|
+
# COMANDOS DE DESARROLLO INTERACTIVO
|
|
103
|
+
# =============================================
|
|
104
|
+
|
|
105
|
+
# Abre una consola interactiva (IRB) con la gema cargada
|
|
106
|
+
# Útil para probar código manualmente
|
|
107
|
+
.PHONY: console
|
|
108
|
+
console:
|
|
109
|
+
@echo "$(BLUE)💻 Abriendo consola interactiva...$(NC)"
|
|
110
|
+
bin/console
|
|
111
|
+
|
|
112
|
+
# =============================================
|
|
113
|
+
# COMANDOS DE PUBLICACIÓN (RELEASE)
|
|
114
|
+
# =============================================
|
|
115
|
+
|
|
116
|
+
# PASO 1: Actualiza la versión en version.rb
|
|
117
|
+
# Debes hacerlo manualmente antes de release
|
|
118
|
+
|
|
119
|
+
# PASO 2: Crea un git tag con la versión
|
|
120
|
+
# Ejemplo: make tag VERSION=0.1.0
|
|
121
|
+
.PHONY: tag
|
|
122
|
+
tag:
|
|
123
|
+
ifndef VERSION
|
|
124
|
+
$(error VERSION no está definido. Usa: make tag VERSION=0.1.0)
|
|
125
|
+
endif
|
|
126
|
+
@echo "$(YELLOW)🏷️ Creando tag v$(VERSION)...$(NC)"
|
|
127
|
+
git add -A
|
|
128
|
+
git commit -m "chore: release v$(VERSION)"
|
|
129
|
+
git tag -a v$(VERSION) -m "Release v$(VERSION)"
|
|
130
|
+
@echo "$(GREEN)✓ Tag creado. Ahora haz: git push origin main --tags$(NC)"
|
|
131
|
+
|
|
132
|
+
# PASO 3 (MANUAL): Publica la gema a RubyGems manualmente
|
|
133
|
+
# Solo úsalo si NO estás usando GitHub Actions
|
|
134
|
+
.PHONY: release-manual
|
|
135
|
+
release-manual:
|
|
136
|
+
@echo "$(YELLOW)📦 Construyendo gema...$(NC)"
|
|
137
|
+
gem build better_auth.gemspec
|
|
138
|
+
@echo "$(YELLOW)🚀 Publicando a RubyGems...$(NC)"
|
|
139
|
+
gem push better_auth-*.gem
|
|
140
|
+
@echo "$(GREEN)✓ Gema publicada$(NC)"
|
|
141
|
+
|
|
142
|
+
# =============================================
|
|
143
|
+
# COMANDOS DE BASES DE DATOS (TESTING)
|
|
144
|
+
# =============================================
|
|
145
|
+
|
|
146
|
+
# Inicia los contenedores de Docker para testing
|
|
147
|
+
# (PostgreSQL, MySQL, Redis)
|
|
148
|
+
.PHONY: db-up
|
|
149
|
+
db-up:
|
|
150
|
+
@echo "$(BLUE)🐳 Iniciando bases de datos...$(NC)"
|
|
151
|
+
docker-compose up -d
|
|
152
|
+
@echo "$(GREEN)✓ Bases de datos listas$(NC)"
|
|
153
|
+
|
|
154
|
+
# Detiene los contenedores de Docker
|
|
155
|
+
.PHONY: db-down
|
|
156
|
+
db-down:
|
|
157
|
+
@echo "$(BLUE)🐳 Deteniendo bases de datos...$(NC)"
|
|
158
|
+
docker-compose down
|
|
159
|
+
@echo "$(GREEN)✓ Bases de datos detenidas$(NC)"
|
|
160
|
+
|
|
161
|
+
# =============================================
|
|
162
|
+
# COMANDOS DE LIMPIEZA
|
|
163
|
+
# =============================================
|
|
164
|
+
|
|
165
|
+
# Limpia archivos temporales y la gema compilada
|
|
166
|
+
.PHONY: clean
|
|
167
|
+
clean:
|
|
168
|
+
@echo "$(BLUE)🧹 Limpiando archivos temporales...$(NC)"
|
|
169
|
+
rm -rf *.gem coverage/ .bundle/
|
|
170
|
+
@echo "$(GREEN)✓ Limpieza completada$(NC)"
|
|
171
|
+
|
|
172
|
+
# =============================================
|
|
173
|
+
# AYUDA
|
|
174
|
+
# =============================================
|
|
175
|
+
|
|
176
|
+
# Muestra todos los comandos disponibles con descripción
|
|
177
|
+
.PHONY: help
|
|
178
|
+
help:
|
|
179
|
+
@echo "$(GREEN)Better Auth Ruby - Comandos disponibles:$(NC)"
|
|
180
|
+
@echo ""
|
|
181
|
+
@echo "$(YELLOW)Instalación:$(NC)"
|
|
182
|
+
@echo " make install - Instala dependencias (bundle install)"
|
|
183
|
+
@echo " make setup - Configuración inicial del proyecto"
|
|
184
|
+
@echo ""
|
|
185
|
+
@echo "$(YELLOW)Desarrollo:$(NC)"
|
|
186
|
+
@echo " make console - Abre consola interactiva (IRB)"
|
|
187
|
+
@echo " make lint - Revisa estilo de código"
|
|
188
|
+
@echo " make lint-fix - Corrige estilo automáticamente"
|
|
189
|
+
@echo ""
|
|
190
|
+
@echo "$(YELLOW)Testing:$(NC)"
|
|
191
|
+
@echo " make test - Ejecuta todos los tests"
|
|
192
|
+
@echo " make test-core - Solo tests del core (Minitest)"
|
|
193
|
+
@echo " make test-rails - Solo tests Rails (RSpec)"
|
|
194
|
+
@echo " make test-coverage - Tests con reporte de cobertura"
|
|
195
|
+
@echo " make ci - Ejecuta CI completo (lint + test)"
|
|
196
|
+
@echo ""
|
|
197
|
+
@echo "$(YELLOW)Bases de datos (Docker):$(NC)"
|
|
198
|
+
@echo " make db-up - Inicia PostgreSQL, MySQL, Redis"
|
|
199
|
+
@echo " make db-down - Detiene contenedores"
|
|
200
|
+
@echo ""
|
|
201
|
+
@echo "$(YELLOW)Release:$(NC)"
|
|
202
|
+
@echo " make tag VERSION=x.x.x - Crea git tag para release"
|
|
203
|
+
@echo " make release-manual - Publica manualmente (NO usar con CI)"
|
|
204
|
+
@echo ""
|
|
205
|
+
@echo "$(YELLOW)Utilidades:$(NC)"
|
|
206
|
+
@echo " make clean - Limpia archivos temporales"
|
|
207
|
+
@echo " make help - Muestra esta ayuda"
|
data/README.md
ADDED
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<h2 align="center">
|
|
3
|
+
Better Auth Ruby
|
|
4
|
+
</h2>
|
|
5
|
+
|
|
6
|
+
<p align="center">
|
|
7
|
+
The most comprehensive authentication framework for Ruby
|
|
8
|
+
<br />
|
|
9
|
+
<a href="https://better-auth.com"><strong>Learn more »</strong></a>
|
|
10
|
+
<br />
|
|
11
|
+
<br />
|
|
12
|
+
<a href="https://discord.gg/better-auth">Discord</a>
|
|
13
|
+
·
|
|
14
|
+
<a href="https://better-auth.com">Website</a>
|
|
15
|
+
·
|
|
16
|
+
<a href="https://github.com/sebasxsala/better-auth/issues">Issues</a>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
[](https://rubygems.org/gems/better_auth)
|
|
20
|
+
[](https://github.com/sebasxsala/better-auth/stargazers)
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
## About the Project
|
|
24
|
+
|
|
25
|
+
Better Auth Ruby is a comprehensive authentication and authorization library for Ruby. It provides a complete set of features out of the box and includes a plugin ecosystem that simplifies adding advanced functionalities with minimal code.
|
|
26
|
+
|
|
27
|
+
### Features
|
|
28
|
+
|
|
29
|
+
- **Framework Agnostic Core**: Works with any Rack-based application
|
|
30
|
+
- **Rails Integration**: First-class Rails support with middleware and helpers
|
|
31
|
+
- **Session Management**: Secure session handling
|
|
32
|
+
- **Multiple Authentication Methods**: Email/password, OAuth, JWT, and more
|
|
33
|
+
- **Two-Factor Authentication**: TOTP and WebAuthn support
|
|
34
|
+
- **Plugin System**: Extensible architecture for custom features
|
|
35
|
+
|
|
36
|
+
## Installation
|
|
37
|
+
|
|
38
|
+
Add this line to your application's Gemfile:
|
|
39
|
+
|
|
40
|
+
```ruby
|
|
41
|
+
gem 'better_auth'
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
And then execute:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
bundle install
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Or install it yourself as:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
gem install better_auth
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
### Basic Setup
|
|
59
|
+
|
|
60
|
+
```ruby
|
|
61
|
+
require 'better_auth'
|
|
62
|
+
|
|
63
|
+
# Configure Better Auth
|
|
64
|
+
BetterAuth.configure do |config|
|
|
65
|
+
config.secret_key = ENV['BETTER_AUTH_SECRET']
|
|
66
|
+
config.database_url = ENV['DATABASE_URL']
|
|
67
|
+
end
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Rails Integration
|
|
71
|
+
|
|
72
|
+
Add to your Gemfile:
|
|
73
|
+
|
|
74
|
+
```ruby
|
|
75
|
+
gem 'better_auth', require: 'better_auth/rails'
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then in your ApplicationController:
|
|
79
|
+
|
|
80
|
+
```ruby
|
|
81
|
+
class ApplicationController < ActionController::Base
|
|
82
|
+
include BetterAuth::Rails::ControllerHelpers
|
|
83
|
+
end
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Now you have access to `current_user` and authentication methods:
|
|
87
|
+
|
|
88
|
+
```ruby
|
|
89
|
+
class PostsController < ApplicationController
|
|
90
|
+
before_action :authenticate_user!
|
|
91
|
+
|
|
92
|
+
def index
|
|
93
|
+
@posts = current_user.posts
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Development
|
|
99
|
+
|
|
100
|
+
### Quick Start
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# 1. Clone the repository
|
|
104
|
+
git clone https://github.com/sebasxsala/better-auth.git
|
|
105
|
+
cd better-auth/packages/better_auth
|
|
106
|
+
|
|
107
|
+
# 2. Install dependencies
|
|
108
|
+
make install
|
|
109
|
+
# or: bundle install
|
|
110
|
+
|
|
111
|
+
# 3. Run tests to verify everything works
|
|
112
|
+
make ci
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Common Make Commands
|
|
116
|
+
|
|
117
|
+
We use a **Makefile** to simplify commands. All have explanatory comments:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# View all available commands with description
|
|
121
|
+
make help
|
|
122
|
+
|
|
123
|
+
# Development
|
|
124
|
+
make console # Interactive console with gem loaded
|
|
125
|
+
make lint # Check code style
|
|
126
|
+
make lint-fix # Auto-fix style issues
|
|
127
|
+
|
|
128
|
+
# Testing
|
|
129
|
+
make test # Run all tests
|
|
130
|
+
make test-core # Only core tests (Minitest)
|
|
131
|
+
make test-coverage # Tests with coverage
|
|
132
|
+
make ci # Full CI (lint + test)
|
|
133
|
+
|
|
134
|
+
# Databases for testing
|
|
135
|
+
make db-up # Start PostgreSQL, MySQL, Redis
|
|
136
|
+
make db-down # Stop containers
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Branch Workflow
|
|
140
|
+
|
|
141
|
+
This project uses a branch model similar to the upstream:
|
|
142
|
+
|
|
143
|
+
**Main Branches:**
|
|
144
|
+
|
|
145
|
+
- **`main`**: Stable code, ready for production
|
|
146
|
+
- **`canary`**: Development/integration branch (like "development" but specific name)
|
|
147
|
+
- "Canary" comes from "canary in a coal mine" - where changes are tested before production
|
|
148
|
+
- Feature PRs go to `canary`
|
|
149
|
+
- When `canary` is stable, merge to `main` for release
|
|
150
|
+
|
|
151
|
+
**Typical workflow:**
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
# 1. Create your feature branch from canary
|
|
155
|
+
git checkout canary
|
|
156
|
+
git pull origin canary
|
|
157
|
+
git checkout -b feat/new-feature
|
|
158
|
+
|
|
159
|
+
# 2. Make your changes and commits
|
|
160
|
+
# ... code ...
|
|
161
|
+
git add .
|
|
162
|
+
git commit -m "feat(core): add support for X"
|
|
163
|
+
|
|
164
|
+
# 3. Push and create PR towards canary
|
|
165
|
+
git push origin feat/new-feature
|
|
166
|
+
# Create PR on GitHub towards canary
|
|
167
|
+
|
|
168
|
+
# 4. Once merged to canary and tested,
|
|
169
|
+
# merge canary → main for release
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
**Why canary instead of development?**
|
|
173
|
+
|
|
174
|
+
- Common name in projects with frequent releases
|
|
175
|
+
- Suggests it's an "experimental" version that might break
|
|
176
|
+
- Allows multiple levels: feature → canary → main
|
|
177
|
+
|
|
178
|
+
### How CI/CD Works
|
|
179
|
+
|
|
180
|
+
**Pull Requests:**
|
|
181
|
+
- Each PR runs: lint + tests on Ruby 3.2 and 3.3
|
|
182
|
+
- Everything must pass before merging
|
|
183
|
+
|
|
184
|
+
**Automatic Release (GitHub Actions):**
|
|
185
|
+
|
|
186
|
+
Release is triggered on `push` to `main` when `lib/better_auth/version.rb` changes.
|
|
187
|
+
|
|
188
|
+
```bash
|
|
189
|
+
# STEP 1: Update version in lib/better_auth/version.rb
|
|
190
|
+
# Example: VERSION = "0.1.1"
|
|
191
|
+
|
|
192
|
+
# STEP 2: Commit and push to main
|
|
193
|
+
git add lib/better_auth/version.rb
|
|
194
|
+
git commit -m "chore: bump version to 0.1.1"
|
|
195
|
+
git push origin main
|
|
196
|
+
|
|
197
|
+
# STEP 3: GitHub Actions automatically:
|
|
198
|
+
# - Runs tests
|
|
199
|
+
# - Builds the gem
|
|
200
|
+
# - Publishes to RubyGems (if version is new)
|
|
201
|
+
# - Creates and pushes git tag (v0.1.1)
|
|
202
|
+
# - Creates GitHub Release
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Required GitHub Configuration:**
|
|
206
|
+
|
|
207
|
+
1. Go to Settings → Secrets and variables → Actions
|
|
208
|
+
2. Add `RUBYGEMS_API_KEY` with your RubyGems API key
|
|
209
|
+
3. The workflow `.github/workflows/release.yml` does the rest
|
|
210
|
+
|
|
211
|
+
**Dry-run options:**
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# Local packaging dry-run
|
|
215
|
+
make release-check
|
|
216
|
+
|
|
217
|
+
# CI dry-run from GitHub Actions
|
|
218
|
+
# Actions -> Release -> Run workflow -> dry_run=true
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Manual Release (without GitHub Actions)
|
|
222
|
+
|
|
223
|
+
Only if you need to do a manual release:
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
# 1. Update version.rb
|
|
227
|
+
# 2. Build the gem
|
|
228
|
+
gem build better_auth.gemspec
|
|
229
|
+
|
|
230
|
+
# 3. Publish (you need to be logged into RubyGems)
|
|
231
|
+
gem push better_auth-*.gem
|
|
232
|
+
|
|
233
|
+
# 4. Create and push the tag
|
|
234
|
+
git tag -a v0.1.1 -m "Release v0.1.1"
|
|
235
|
+
git push origin --tags
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Project Structure
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
lib/
|
|
242
|
+
better_auth.rb # Entry point
|
|
243
|
+
better_auth/
|
|
244
|
+
version.rb # Gem version
|
|
245
|
+
core.rb # Core loader
|
|
246
|
+
core/ # Core logic (framework-agnostic)
|
|
247
|
+
|
|
248
|
+
test/ # Core tests (Minitest)
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
**Conventions:**
|
|
252
|
+
- Core: Framework-agnostic, uses Minitest
|
|
253
|
+
- All code goes through StandardRB (Ruby style guide)
|
|
254
|
+
|
|
255
|
+
## Contributing
|
|
256
|
+
|
|
257
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/sebasxsala/better-auth. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/sebasxsala/better-auth/blob/main/CODE_OF_CONDUCT.md).
|
|
258
|
+
|
|
259
|
+
## License
|
|
260
|
+
|
|
261
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
262
|
+
|
|
263
|
+
## Security
|
|
264
|
+
|
|
265
|
+
If you discover a security vulnerability within Better Auth Ruby, please send an e-mail to [security@better-auth.com](mailto:security@better-auth.com).
|
|
266
|
+
|
|
267
|
+
All reports will be promptly addressed, and you'll be credited accordingly.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rake/testtask"
|
|
5
|
+
|
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
|
7
|
+
t.libs << "test"
|
|
8
|
+
t.libs << "lib"
|
|
9
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
desc "Run StandardRB linter"
|
|
13
|
+
task :lint do
|
|
14
|
+
sh "bundle exec standardrb"
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
desc "Auto-fix StandardRB issues"
|
|
18
|
+
task "lint:fix" do
|
|
19
|
+
sh "bundle exec standardrb --fix"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
desc "Run full CI check (lint + test)"
|
|
23
|
+
task ci: [:lint, :test]
|
|
24
|
+
|
|
25
|
+
task default: :ci
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
### Reporting a Vulnerability
|
|
4
|
+
|
|
5
|
+
If you believe you've found a security vulnerability, please follow these steps:
|
|
6
|
+
|
|
7
|
+
1. Do not disclose the vulnerability publicly until it has been addressed by our
|
|
8
|
+
team.
|
|
9
|
+
2. Email your findings to `security@better-auth.com` Include:
|
|
10
|
+
* A description of the vulnerability
|
|
11
|
+
* Steps to reproduce the vulnerability
|
|
12
|
+
* Potential impact of the vulnerability
|
|
13
|
+
* Any suggestions for mitigation
|
|
14
|
+
* Any other relevant information
|
|
15
|
+
3. We will respond to your report within 72 hours.
|
|
16
|
+
4. If the issue is confirmed, we will release a patch as soon as possible.
|
|
17
|
+
|
|
18
|
+
### Disclosure Policy
|
|
19
|
+
|
|
20
|
+
If the issue is confirmed, we will release a patch as soon as possible.
|
|
21
|
+
Once a patch is released, we will disclose the issue publicly.
|
|
22
|
+
If 90 days has elapsed and we still don't have a fix, we will disclose the issue
|
|
23
|
+
publicly.
|
|
24
|
+
|
|
25
|
+
## Supported Versions
|
|
26
|
+
|
|
27
|
+
We only support the latest version of Better Auth Ruby.
|
|
28
|
+
Older versions are not supported.
|
data/docker-compose.yml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Services for testing database adapters
|
|
2
|
+
# These are used in CI for testing various database backends
|
|
3
|
+
|
|
4
|
+
x-postgres-healthcheck: &postgres-healthcheck
|
|
5
|
+
healthcheck:
|
|
6
|
+
test: ["CMD-SHELL", "pg_isready -U user -d better_auth"]
|
|
7
|
+
interval: 1s
|
|
8
|
+
timeout: 5s
|
|
9
|
+
retries: 10
|
|
10
|
+
|
|
11
|
+
x-mysql-healthcheck: &mysql-healthcheck
|
|
12
|
+
healthcheck:
|
|
13
|
+
test: ["CMD", "mysqladmin", "ping", "-h", "127.0.0.1", "-uuser", "-ppassword"]
|
|
14
|
+
interval: 1s
|
|
15
|
+
timeout: 5s
|
|
16
|
+
retries: 10
|
|
17
|
+
start_period: 30s
|
|
18
|
+
|
|
19
|
+
services:
|
|
20
|
+
redis:
|
|
21
|
+
image: redis:latest
|
|
22
|
+
container_name: redis
|
|
23
|
+
ports:
|
|
24
|
+
- "6379:6379"
|
|
25
|
+
volumes:
|
|
26
|
+
- redis_data:/data
|
|
27
|
+
healthcheck:
|
|
28
|
+
test: ["CMD", "redis-cli", "ping"]
|
|
29
|
+
interval: 1s
|
|
30
|
+
timeout: 5s
|
|
31
|
+
retries: 10
|
|
32
|
+
|
|
33
|
+
postgres:
|
|
34
|
+
<<: *postgres-healthcheck
|
|
35
|
+
image: postgres:latest
|
|
36
|
+
container_name: postgres
|
|
37
|
+
environment:
|
|
38
|
+
POSTGRES_USER: user
|
|
39
|
+
POSTGRES_PASSWORD: password
|
|
40
|
+
POSTGRES_DB: better_auth
|
|
41
|
+
ports:
|
|
42
|
+
- "5432:5432"
|
|
43
|
+
volumes:
|
|
44
|
+
- postgres_data:/var/lib/postgresql
|
|
45
|
+
|
|
46
|
+
mysql:
|
|
47
|
+
<<: *mysql-healthcheck
|
|
48
|
+
image: mysql:latest
|
|
49
|
+
container_name: mysql
|
|
50
|
+
environment:
|
|
51
|
+
MYSQL_ROOT_PASSWORD: root_password
|
|
52
|
+
MYSQL_DATABASE: better_auth
|
|
53
|
+
MYSQL_USER: user
|
|
54
|
+
MYSQL_PASSWORD: password
|
|
55
|
+
ports:
|
|
56
|
+
- "3306:3306"
|
|
57
|
+
volumes:
|
|
58
|
+
- mysql_data:/var/lib/mysql
|
|
59
|
+
|
|
60
|
+
volumes:
|
|
61
|
+
redis_data:
|
|
62
|
+
postgres_data:
|
|
63
|
+
mysql_data:
|
data/lib/better_auth.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: better_auth
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Sebastian Sala
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2026-03-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rack
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '3.0'
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '3.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: json
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '2.0'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '2.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: jwt
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '2.8'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '2.8'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: bcrypt
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.1'
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '3.1'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: bundler
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '2.5'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '2.5'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: minitest
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: '5.25'
|
|
90
|
+
type: :development
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: '5.25'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: standardrb
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - "~>"
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '1.0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - "~>"
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '1.0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: rake
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - "~>"
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '13.2'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - "~>"
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '13.2'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: simplecov
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0.22'
|
|
132
|
+
type: :development
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '0.22'
|
|
139
|
+
description: Better Auth is a comprehensive, framework-agnostic authentication library
|
|
140
|
+
for Ruby. It provides a complete set of features out of the box with a plugin ecosystem.
|
|
141
|
+
email:
|
|
142
|
+
- sebastian.sala.tech@gmail.com
|
|
143
|
+
executables: []
|
|
144
|
+
extensions: []
|
|
145
|
+
extra_rdoc_files: []
|
|
146
|
+
files:
|
|
147
|
+
- ".ruby-version"
|
|
148
|
+
- ".standard.yml"
|
|
149
|
+
- ".vscode/settings.json"
|
|
150
|
+
- AGENTS.md
|
|
151
|
+
- CHANGELOG.md
|
|
152
|
+
- CLAUDE.md
|
|
153
|
+
- CODE_OF_CONDUCT.md
|
|
154
|
+
- CONTRIBUTING.md
|
|
155
|
+
- Gemfile
|
|
156
|
+
- LICENSE.md
|
|
157
|
+
- Makefile
|
|
158
|
+
- README.md
|
|
159
|
+
- Rakefile
|
|
160
|
+
- SECURITY.md
|
|
161
|
+
- docker-compose.yml
|
|
162
|
+
- lib/better_auth.rb
|
|
163
|
+
- lib/better_auth/core.rb
|
|
164
|
+
- lib/better_auth/version.rb
|
|
165
|
+
homepage: https://github.com/sebasxsala/better-auth
|
|
166
|
+
licenses:
|
|
167
|
+
- MIT
|
|
168
|
+
metadata:
|
|
169
|
+
homepage_uri: https://github.com/sebasxsala/better-auth
|
|
170
|
+
source_code_uri: https://github.com/sebasxsala/better-auth
|
|
171
|
+
changelog_uri: https://github.com/sebasxsala/better-auth/blob/main/packages/better_auth/CHANGELOG.md
|
|
172
|
+
bug_tracker_uri: https://github.com/sebasxsala/better-auth/issues
|
|
173
|
+
post_install_message:
|
|
174
|
+
rdoc_options: []
|
|
175
|
+
require_paths:
|
|
176
|
+
- lib
|
|
177
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
178
|
+
requirements:
|
|
179
|
+
- - ">="
|
|
180
|
+
- !ruby/object:Gem::Version
|
|
181
|
+
version: 3.2.0
|
|
182
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
|
+
requirements:
|
|
184
|
+
- - ">="
|
|
185
|
+
- !ruby/object:Gem::Version
|
|
186
|
+
version: '0'
|
|
187
|
+
requirements: []
|
|
188
|
+
rubygems_version: 3.5.22
|
|
189
|
+
signing_key:
|
|
190
|
+
specification_version: 4
|
|
191
|
+
summary: Comprehensive authentication framework for Ruby/Rack
|
|
192
|
+
test_files: []
|