work-design / rails_auth

New Wave Auth Engine

Home Page:https://work.design/rails_auth

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RailsAuth

测试 Docker构建 Gem

用于处理鉴权

特性

  • 系列项目说明
  • 使用Rails自带的ActiveModel::SecurePassword模块处理密码;
  • 使用auth_token统一鉴权,兼容 api 和 cookies, 服务端可控制 auth_token 失效;
  • 架构:
    • 为合并用户提供了灵活的架构基础;
    • 支持多终端登录;
    • 采用全局唯一 User 设计,通过 UserTag 标签
    • 在部分场景下,通过UserTag自动打标签;

文件说明

如果用户表和项目表分离存贮,注意不要在项目中使用users, accounts, oauth_users任何一张表作为连表查询的中间表。

如何使用

模型:

  • User
  • Account
  • OauthUser
  • App
  • AuthorizedToken: 授权token
  • VerifyToken: 验证Token
class ApplicationController < ActionController::Base
  include Auth::Controller::Application
  before_action :require_login
end

Include in Model

class User < ActiveRecord::Base
  include Auth::Model::User
end

The methods RailsAuth provided:

# in controller
current_user

# in view with helper method
current_user

许可证

遵循 MIT 协议

About

New Wave Auth Engine

https://work.design/rails_auth

License:MIT License


Languages

Language:HTML 51.3%Language:Ruby 48.7%