Better Auth Ruby
A modern authentication framework for Ruby, inspired by Better Auth.
This project is independent and is not affiliated with, maintained by, or endorsed by the Better Auth project.
Ruby server packages for Better Auth. The core is Rack-first, with adapters for Rails, Sinatra, and Hanami, plus Ruby packages for selected Better Auth plugins.
Documentation - Supported features - Upstream Better Auth - Issues
Current upstream target: Better Auth v1.6.9.
This project is active work. The Ruby port implements a large server-side surface, but exact upstream parity is still being tightened across some routes, adapter edge cases, OpenAPI schemas, and docs pages.
Install
Rails
# Gemfile
gem "better_auth-rails"bundle install
bin/rails generate better_auth:install# config/routes.rb
Rails.application.routes.draw do
better_auth
endRack
# Gemfile
gem "better_auth"require "better_auth"
auth = BetterAuth.auth(
secret: ENV.fetch("BETTER_AUTH_SECRET"),
base_url: "http://localhost:3000",
database: BetterAuth::Adapters::Memory.new
)
run authSinatra
# Gemfile
gem "better_auth-sinatra"require "sinatra/base"
require "better_auth/sinatra"
class App < Sinatra::Base
register BetterAuth::Sinatra
better_auth at: "/api/auth" do |config|
config.secret = ENV.fetch("BETTER_AUTH_SECRET")
config.base_url = ENV.fetch("BETTER_AUTH_URL")
config.database = ->(options) {
BetterAuth::Adapters::Postgres.new(options, url: ENV.fetch("DATABASE_URL"))
}
end
endHanami
# Gemfile
gem "better_auth-hanami"bundle install
bundle exec rake better_auth:init
bin/hanami db migrateSupported Features
See the docs page for the current support inventory:
Short version:
- Rack core, Rails, Sinatra, and Hanami integration packages exist.
- Email/password, sessions, social OAuth, database adapters, and many server plugins are implemented with Ruby tests.
- Payment docs and navigation only list Stripe. Other upstream payment plugins are intentionally not marked as supported.
- Browser client packages and TypeScript-only helpers are outside the Ruby server scope unless a Ruby package explicitly documents an equivalent.
Packages
-
better_auth: Rack core, auth routes, sessions, cookies, adapters, plugin system, and built-in server plugins. -
better_auth-rails: Rails mount helpers, ActiveRecord adapter, controller helpers, migrations, and generators. -
better_auth-sinatra: Sinatra extension, Rack mounting, helpers, and migration tasks. -
better_auth-hanami: Hanami integration, action helpers, Sequel adapter, migrations, and generators. -
better_auth-mongo-adapter: MongoDB database adapter. -
better_auth-redis-storage: Redis secondary storage. -
better_auth-api-key: API key plugin package. -
better_auth-passkey: Passkey/WebAuthn plugin package. -
better_auth-oauth-provider: OAuth 2.0/OIDC provider plugin package. -
better_auth-scim: SCIM v2 provisioning plugin package. -
better_auth-sso: OIDC and SAML SSO plugin package. -
better_auth-stripe: Stripe billing plugin package.
OpenAuth alias packages are also available for users who prefer that naming. They install and load the matching Better Auth Ruby packages, and their READMEs point back to the canonical documentation at https://better-auth-rb.vercel.app/.
-
openauth: Alias forbetter_auth. -
openauth-rails: Alias forbetter_auth-rails. -
openauth-sinatra: Alias forbetter_auth-sinatra. -
openauth-hanami: Alias forbetter_auth-hanami. -
openauth-mongodb: Alias forbetter_auth-mongo-adapter. -
openauth-redis-storage: Alias forbetter_auth-redis-storage. -
openauth-api-key: Alias forbetter_auth-api-key. -
openauth-passkey: Alias forbetter_auth-passkey. -
openauth-oauth-provider: Alias forbetter_auth-oauth-provider. -
openauth-scim: Alias forbetter_auth-scim. -
openauth-sso: Alias forbetter_auth-sso. -
openauth-stripe: Alias forbetter_auth-stripe.
Development
git clone --recursive https://github.com/sebasxsala/better-auth.git
cd better-auth
make install
make ciRun a single package:
cd packages/better_auth
bundle exec rake testDatabase-backed tests may require the repo services:
docker compose up -dContributing
- Branch from
canary. - Read
AGENTS.mdand the package-specific instructions before editing a package. - Check upstream source and tests for behavior changes.
- Run the relevant package tests, or
make cifor the full repo. - Open a PR to
canary.
Security
Report vulnerabilities to security@openparcel.dev. See SECURITY.md.