wolox / wor-authentication Goto Github PK
View Code? Open in Web Editor NEWGem to add authentication to your application using JWT, with expirable, renewable and customizable tokens!
License: MIT License
Gem to add authentication to your application using JWT, with expirable, renewable and customizable tokens!
License: MIT License
When I redefine this method entity_custom_validation_value
in my api controller, if the entity is nil, it's impossible to do anything like entity.some_value
, because it throws 500.
Add a new entrance to the Wiki so the users know how to use this gem together with Devise.
According to the experience that @Dinuuu & @santyalcala had in the training, it's hard to test controllers that uses this gems, we need to fix this in some way
I think that the gem was created to add Authentication to any model that we want to, but in the README you are always talking about Users which may mislead some persons, for example:
def new_token_expiration_date
(Time.zone.now + 2.days).to_i
end
def token_maximum_useful_date
(Time.zone.now + 30.days).to_i
end
In the methods listed above I wouldn't use .to_i
because if you use it, you are not returning dates, just an integer, and also I would use the from_now
method, for example, 2.days.from_now
In the README file there is an example for authenticate_entity
that is
# authentication_controller.rb
def authenticate_entity(params)
user ||= User.find_by(email: params[:email])
return nil unless user.present? && user.valid_password?(params[:password])
end
This method uses memoization when it shouldn't (in my opinion) and also returns nil
always
Add to readme about a possible implementation of current_entity
method
let!(:access_data) { AuthenticationController.new.generate_access_token({}) }
in:
def authentication_token
request.headers['Authorization'].split(' ').last
end
If Authorization
header is not present, it explodes with:
NoMethodError: undefined method 'split' for nil:NilClass
You should be able to do something like this:
Wor::Authentication::SessionsController.generate_access_token(User.first)
But it fails in the line 33 -> renew_id = token_renew_id
, because token_renew_id
is a method from: Wor::Authentication::Controller
We shall move this method inside Wor::Authentication::SessionsController
, because it's the only place where it's used
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.