kemal_jwt_auth

Version, currently 1.0.02 versions

github.com/dscottboggs/kemal-jwt-auth

Drop-in authentication for Kemal using JWTs

6 stars
0 dependents
License: MIT

Nothing has been indexed for 1.0.0 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.

Installation

# Add this to your shard.yml
dependencies:
  kemal_jwt_auth:
    github: dscottboggs/kemal-jwt-auth
    version: ~> 1.0.0

Then run:

shards install

shard.yml

No shard.yml has been indexed for 1.0.0. You can read it on the repository.

Dependencies

Unknown: the shard.yml for this version has not been read yet.

README

This README is the one indexed from the repository at its latest ref, not from the tag for this version.

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

  1. Add the dependency to your shard.yml:

    dependencies:
      kemal_jwt_auth:
        github: dscottboggs/kemal_jwt_auth
        version: ~> 1.0
  2. Run shards install

Contributing

  1. Fork it (https://github.com/dscottboggs/kemal_jwt_auth/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors