kemal-jwt-auth v1.0.1
Kemal JWT Authentication
Drop-in authentication middleware for Kemal, independent of user model. See example.cr for a full example.
TL;DR:
require "kemal"
require "kemal_jwt_auth"
# you can use your existing users collection data-structure.
require "./my_users"
# Your `MyUsers` must include the `KemalJWTAuth::UsersCollection` module
collection = MyUsers.default_config
add_handler KemalJWTAuth::Handler.new users: collection
get "/test" do |context|
if user = context.current_user?
"Welcome, #{user}!"
else
"no user found"
end
end
Kemal.run
JavaScript companion
There is a JavaScript companion library to make using this library with an SPA or other JavaScript client a cinch. See the client repository for more information
Installation
-
Add the dependency to your
shard.yml
:dependencies: kemal_jwt_auth: github: dscottboggs/kemal_jwt_auth version: ~> 1.0
-
Run
shards install
Contributing
- Fork it (https://github.com/dscottboggs/kemal_jwt_auth/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Contributors
- D. Scott Boggs - creator and maintainer
Repository
kemal-jwt-auth
Owner
Statistic
- 6
- 1
- 0
- 0
- 3
- over 5 years ago
- March 10, 2019
License
MIT License
Links
Synced at
Sun, 17 Nov 2024 07:44:54 GMT
Languages