# Inertia Rails Auth

> Implement authentication and authorization in Inertia Rails applications. Use when setting up login, sessions, permissions, and access control with Devise, has_secure_password, or other auth solutions.

- **Type:** Skill
- **Install:** `agentstack add skill-cole-robertson-inertia-rails-skills-inertia-rails-auth`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [cole-robertson](https://agentstack.voostack.com/s/cole-robertson)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [cole-robertson](https://github.com/cole-robertson)
- **Source:** https://github.com/cole-robertson/inertia-rails-skills/tree/main/skills/inertia-rails-auth

## Install

```sh
agentstack add skill-cole-robertson-inertia-rails-skills-inertia-rails-auth
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Inertia Rails Authentication & Authorization

Guide to implementing authentication and authorization in Inertia Rails applications.

## Key Principle

Inertia uses your existing Rails authentication infrastructure. No special OAuth or token-based auth required. Since your frontend and backend share the same domain, session-based auth works seamlessly.

## Authentication with Devise

### Setup

```ruby
# Gemfile
gem 'devise'
```

```bash
bundle install
rails generate devise:install
rails generate devise User
rails db:migrate
```

### Share Authentication State

```ruby
# app/controllers/application_controller.rb
class ApplicationController  reset('password'),
    })
  }

  return (
    
      Sign In

      
        Email
         setData('email', e.target.value)}
          autoFocus
        />
        {errors.email && {errors.email}}
      

      
        Password
         setData('password', e.target.value)}
        />
      

      
        
           setData('remember', e.target.checked)}
          />
          Remember me
        
      

      
        {processing ? 'Signing in...' : 'Sign In'}
      

      
        Create an account
        Forgot password?
      
    
  )
}
```

### Login Component (Vue)

```vue

import { useForm, Link } from '@inertiajs/vue3'

const form = useForm({
  email: '',
  password: '',
  remember: false,
})

function submit() {
  form.post('/users/sign_in', {
    onSuccess: () => form.reset('password'),
  })
}

  
    Sign In

    
      Email
      
      {{ form.errors.email }}
    

    
      Password
      
    

    
      
        
        Remember me
      
    

    
      {{ form.processing ? 'Signing in...' : 'Sign In' }}
    

    
      Create an account
      Forgot password?
    
  

```

## Authentication with has_secure_password

### User Model

```ruby
# app/models/user.rb
class User 
      Users

      {can.create_user && (
        
          Create User
        
      )}

      
        {users.map((user) => (
          
            {user.name}

            {user.can.edit && (
              Edit
            )}

            {user.can.delete && (
              
                Delete
              
            )}
          
        ))}
      
    
  )
}
```

### Frontend Permission Checks (Vue)

```vue

import { Link, usePage } from '@inertiajs/vue3'

const props = defineProps(['users', 'can'])
const { auth } = usePage().props

  
    Users

    
    
      Create User
    

    
      
        {{ user.name }}

        
        
          Edit
        

        
          Delete
        
      
    
  

```

## History Encryption

Prevent sensitive data exposure via browser back button after logout:

```ruby
# config/initializers/inertia_rails.rb
InertiaRails.configure do |config|
  # Enable globally
  config.encrypt_history = true
end

# Or per-controller for sensitive areas
class Admin::BaseController  {
  const { auth } = usePage().props
  if (!auth.signed_in && requiresAuth(page.component)) {
    router.visit('/login')
  }
})
```

### 5. Implement Rate Limiting

```ruby
# Gemfile
gem 'rack-attack'

# config/initializers/rack_attack.rb
Rack::Attack.throttle('login attempts', limit: 5, period: 60) do |req|
  req.ip if req.path == '/login' && req.post?
end
```

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [cole-robertson](https://github.com/cole-robertson)
- **Source:** [cole-robertson/inertia-rails-skills](https://github.com/cole-robertson/inertia-rails-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** yes
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** yes
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-cole-robertson-inertia-rails-skills-inertia-rails-auth
- Seller: https://agentstack.voostack.com/s/cole-robertson
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
