Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Minato Rails Auth is a library designed to be an authentication layer in Rails applications. It has a JWT module, that can be included in Rails Controllers to authenticate requests. And has a RSpec shared contexts, to simplify authentication in automated tests.
The recommended installation way is by Gem or Bundler:
$ gem install minato-rails-auth
$ bundle add minato-rails-auth
Or just add the following line on your Gemfile
file:
gem 'minato-rails-auth'
And you can specify the version:
gem 'minato-rails-auth', '~> 0.1.0'
To configure the Minato Rails Auth lib on your Rails application, is necessary to follow the steps:
Create a configuration file:
[rails-app]/config/initializers/minato_rails_auth.rb
Add the following content in the file:
require 'minato/rails/auth'
Minato::Rails::Auth.configure do |conf|
conf.jwt.issuer = Settings.api.secure.issuer
conf.jwt.jwks_uri = Settings.api.secure.jwks_uri
end
Each option specs:
conf.jwt
conf.jwt.issuer
conf.jwt.jwks_uri
conf.jwt.jwks
conf.jwt.algorithms
conf.jwt.verify_iss
conf.jwt.verify_token_signature
conf.jwt.hmac_secret
conf.jwt.additional_params
And now, the library was configured in your Rails application.
To add the JWT authentication system in your Rails application, just follow the steps:
Include the JWT module in your ApplicationController
:
class ApplicationController < ActionController::API
include Minato::Rails::Auth::JWT
end
Now it is available the method authenticate_request!
in your controllers, and you can call it when you want to auth a controller:
class FooController < ApplicationController
before_action :authenticate_request!
end
Now the variable current_user
is availabe in your controller, containing the following methods:
.machine?
.human?
.machine?
method, but tells you if the client is human..session
.machine
The Minato Rails Auth makes available the RSpec shared contexts, to make it available you can include the module in your [rails-app]/spec/spec_helper.rb
:
require 'minato/rails/auth/spec'
And now it will be available the following shared contexts, that you can use following the docs:
with jwt authentication
:
jwt_payload
variable using let
.with human jwt authentication
:
jwt_email
, jwt_account_id
, jwt_session_id
, jwt_identity_id
and jwt_payload
.with machine jwt authentication
:
jwt_machine
.with missing jwt authentication
:
::JWT::VerificationError
, simulating when the user is not authenticated.After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/ferreri/minato/minato-rails-auth.
FAQs
Unknown package
We found that minato-rails-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.