Project

zevauth

0.0
The project is in a healthy, maintained state
Verifies ZevAuth session tokens (RS256, keys fetched and rotated for you), reads who is signed in from a bearer token or the session-bridge cookie, calls the ZevAuth backend API with your secret key, and checks webhook signatures. Includes Rack middleware and an optional Rails engine.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 2.7, < 4
 Project Readme

ZevAuth for Ruby

Verify ZevAuth sessions, call the ZevAuth backend API and check webhook signatures from Rails, Rack apps (Sinatra, Roda, Hanami) or plain Ruby.

gem "zevauth"

Ruby 3.1 or later. One runtime dependency (jwt, to read published keys); Rack and Rails are used when your app has them and never required.

Configure

ZevAuth.configure do |c|
  c.environment_id  = ENV.fetch("ZEVAUTH_ENVIRONMENT_ID")   # env_live_…
  c.secret_key      = ENV.fetch("ZEVAUTH_SECRET_KEY")       # sk_live_…, backend API only
  c.publishable_key = ENV.fetch("ZEVAUTH_PUBLISHABLE_KEY")  # pk_live_…, for the handshake page
  c.webhook_secret  = ENV.fetch("ZEVAUTH_WEBHOOK_SECRET")   # whsec_…
end

Who is signed in

auth = ZevAuth.get_auth(request)   # never raises for a missing or bad token
auth.signed_in?
auth.user_id                       # "user_…"
auth.organization_id
auth.has?(permission: "org:members:manage")
auth.mfa_verified?

require_auth refuses instead, with the same responses in every ZevAuth SDK: 401 unauthorized, 403 session_task_pending, 403 mfa_required.

ZevAuth.require_auth(request, require_mfa: true)   # raises ZevAuth::AuthRefused

Tokens are checked locally against your environment's published keys (RS256 only, keys cached and rotated for you), so this costs no network call per request.

Rails

# config/routes.rb
mount ZevAuth::Engine => "/zevauth"

# app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
  before_action :require_zevauth!
end

class BillingController < ApplicationController
  require_zevauth only: :update, require_mfa: true
end

Views get zevauth_signed_in?, zevauth_user_id and zevauth_auth.

Rack

use ZevAuth::Rack::Middleware        # env["zevauth.auth"] on every request

map "/api" do
  use ZevAuth::Rack::RequireAuth      # 401 / 403 with the JSON envelope
  run Api
end

Backend API

client = ZevAuth.client
client.users.get("user_123")
client.users.each(metadata: { plan: "pro" }) { |user| puts user["email"] }
client.organizations.add_member("org_123", user_id: "user_123", role: "org:admin")

Errors are ZevAuth::APIError with code, status and request_id. Rate limits and brief outages are retried for you; a 500 never is, so a create cannot run twice.

Webhooks

Verify the raw body, never parsed params:

event = ZevAuth::Webhooks.construct_event(
  payload: request.raw_post,
  signature: request.headers["zevauth-signature"]
)

In a Rails controller, zevauth_webhook_event does the same.

Server-rendered pages

With the session bridge, the browser SDK hands each new access token to your server, which keeps it in its own HttpOnly cookie, so a page knows who is signed in before it renders. Mount the engine (Rails) or the middleware (Rack), and set sessionBridge: { url: "/zevauth/session" } in the browser SDK. Your server never refreshes a token; the browser does.

Documentation

Development

bundle install
bundle exec rake test       # includes the shared conformance fixtures
bundle exec rubocop

test/fixtures is a copy of the shared conformance fixtures from zevauth-sdk. Never edit it by hand: change the fixture in zevauth-sdk, then run script/sync-fixtures here.

Support

Questions and bug reports: open an issue here, or contact ZevAuth support.

License

MIT. Copyright (c) 2026 Zevop Inc.