afal-auth

Provide OmniAuth-based AFAL IdP authentication for Rails applications.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/Grupo-AFAL/claude-plugins --skill afal-auth
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: afal-auth
Source: https://github.com/Grupo-AFAL/claude-plugins/tree/main/rails-tools/skills/afal-auth
Command: npx skills add https://github.com/Grupo-AFAL/claude-plugins --skill afal-auth

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Provides a standardized, secure authentication pattern for AFAL Rails applications that centralizes sign-in through the AFAL IdP and replaces ad-hoc or insecure local auth approaches. It removes ambiguity about credentials handling, session lifecycle, and multi-tenant scoping so teams can implement production-ready SSO consistently.

Core Features & Use Cases

  • OmniAuth Strategy: Custom OAuth2 strategy named afal_idp that retrieves id, email, name, employee_id, roles, and organization from the IdP userinfo endpoint.
  • Session Management: Database-backed Session model for audit trails, tracked via cookies.signed[:session_id] to enable server-side revocation and per-login metadata (user_agent, ip_address).
  • Controller Concern & Current Attributes: Opt-out authentication via a shared Authentication concern that resumes sessions into Current.user and Current.session, with model defaults for multi-tenancy.
  • Security & Testing: Uses Rails.application.credentials for IdP secrets, recommends omniauth-rails_csrf_protection, and includes Minitest patterns and fixtures for reliable test coverage.

Quick Start

Redirect users to /auth/afal_idp, implement SessionsController#create to find or create a User from the OmniAuth hash, create a Session record, and set cookies.signed[:session_id] to the session id.

Frequently Asked Questions about afal-auth

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement OmniAuth SSO with database-backed session management in Rails?

OmniAuth SSO with database-backed session management in Rails is implemented using a custom OAuth2 strategy that creates a Session record tracked via cookies.signed[:session_id] to enable server-side audit trails and revocation.

How does multi-tenant scoping work with IdP authentication in Rails applications?

Multi-tenant scoping with IdP authentication in Rails applications works by retrieving organization data from the IdP userinfo endpoint and applying model defaults through a shared Authentication concern that sets Current.user attributes.

What's the best way to test OmniAuth authentication strategies in Rails with Minitest?

Testing OmniAuth authentication strategies in Rails with Minitest is supported through included Minitest patterns and fixtures that provide reliable test coverage for session creation, user find-or-create logic, and IdP data mapping.

Can I use Rails.application.credentials to manage OmniAuth IdP secrets securely?

Rails.application.credentials can be used to manage OmniAuth IdP secrets securely by storing the OAuth2 client credentials there, which the custom afal_idp strategy reads to authenticate against the AFAL IdP.

Does this OmniAuth setup require omniauth-rails_csrf_protection for controller authentication?

OmniAuth setup requires omniauth-rails_csrf_protection for controller authentication to prevent CSRF attacks during the OAuth2 initiation phase, complementing the opt-out Authentication concern that resumes sessions into Current attributes.

When do I need a custom OAuth2 strategy for centralized SSO in Rails instead of local authentication?

A custom OAuth2 strategy for centralized SSO in Rails is needed instead of local authentication when your applications require standardized sign-in through a central IdP, database-backed session audit trails, and multi-tenant organization scoping.