OmniAuth Rails CSRF 保护项目教程

OmniAuth Rails CSRF 保护项目教程

omniauth-rails_csrf_protectionProvides CSRF protection on OmniAuth request endpoint on Rails application.项目地址:https://gitcode.com/gh_mirrors/om/omniauth-rails_csrf_protection

1、项目的目录结构及介绍

omniauth-rails_csrf_protection/
├── bin/
│   └── console
├── lib/
│   └── omniauth/
│       └── rails_csrf_protection.rb
├── test/
│   └── omniauth_rails_csrf_protection_test.rb
├── .gitignore
├── .rubocop.yml
├── CODE_OF_CONDUCT.md
├── Gemfile
├── LICENSE.txt
├── README.md
├── Rakefile
└── omniauth-rails_csrf_protection.gemspec
  • bin/: 包含用于启动项目控制台的脚本。
  • lib/: 包含项目的主要代码文件,特别是 rails_csrf_protection.rb 文件,该文件实现了 CSRF 保护功能。
  • test/: 包含项目的测试文件,确保功能的正确性。
  • .gitignore: 指定 Git 版本控制系统忽略的文件和目录。
  • .rubocop.yml: 配置 RuboCop 代码风格检查工具的规则。
  • CODE_OF_CONDUCT.md: 项目的代码行为准则。
  • Gemfile: 指定项目依赖的 Gem 包。
  • LICENSE.txt: 项目的许可证文件。
  • README.md: 项目的主要说明文档。
  • Rakefile: 包含 Rake 任务的定义。
  • omniauth-rails_csrf_protection.gemspec: 项目的 Gem 规范文件,包含项目的元数据和依赖信息。

2、项目的启动文件介绍

项目的启动文件主要是 lib/omniauth/rails_csrf_protection.rb。这个文件实现了 CSRF 保护功能,具体包括:

  • 禁用通过 HTTP GET 方法访问 OAuth 请求阶段。
  • 在请求阶段之前插入 Rails CSRF 令牌验证器。

3、项目的配置文件介绍

项目的配置文件主要是 Gemfileomniauth-rails_csrf_protection.gemspec

Gemfile

source 'https://rubygems.org'

gem 'omniauth-rails_csrf_protection'
  • source 'https://rubygems.org': 指定 Gem 包的来源。
  • gem 'omniauth-rails_csrf_protection': 引入 omniauth-rails_csrf_protection 这个 Gem 包。

omniauth-rails_csrf_protection.gemspec

Gem::Specification.new do |spec|
  spec.name          = "omniauth-rails_csrf_protection"
  spec.version       = "0.1.2"
  spec.authors       = ["Cookpad Inc."]
  spec.email         = ["developers@cookpad.com"]
  spec.summary       = %q{Provides CSRF protection on OmniAuth request endpoint on Rails application}
  spec.description   = %q{This gem provides a mitigation against CVE-2015-9284 (Cross-Site Request Forgery on the request phase when using OmniAuth gem with a Ruby on Rails application) by implementing a CSRF token verifier that directly uses ActionController::RequestForgeryProtection code from Rails}
  spec.homepage      = "https://github.com/cookpad/omniauth-rails_csrf_protection"
  spec.license       = "MIT"

  spec.files         = `git ls-files -z`.split("\x0")
  spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
  spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
  spec.require_paths = ["lib"]

  spec.add_dependency "actionpack", ">= 4.2"
  spec.add_dependency "omniauth", ">= 1.3.1"

  spec.add_development_dependency "bundler", "~> 1.16"
  spec.add_development_dependency "rake", "~> 10.0"
  spec.add_development_dependency "minitest", "~> 5.0"
end
  • spec.name: 项目的名称。
  • spec.version: 项目的版本。
  • spec.authors: 项目的作者。

omniauth-rails_csrf_protectionProvides CSRF protection on OmniAuth request endpoint on Rails application.项目地址:https://gitcode.com/gh_mirrors/om/omniauth-rails_csrf_protection

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

姚星依Kyla

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值