All Projects → kemalcr → kemal-basic-auth

kemalcr / kemal-basic-auth

Licence: MIT license
Basic auth for your Kemal application

Programming Languages

crystal
512 projects

Projects that are alternatives of or similar to kemal-basic-auth

kemal-watcher
Kemal plugin to watch files and live-reload the browser
Stars: ✭ 21 (+50%)
Mutual labels:  kemal
serverless-static-hosting-with-basic-auth
Serverless boilerplate for Static website hosting with Basic authentication
Stars: ✭ 21 (+50%)
Mutual labels:  basic-authentication
s3-proxy
S3 Reverse Proxy with GET, PUT and DELETE methods and authentication (OpenID Connect and Basic Auth)
Stars: ✭ 106 (+657.14%)
Mutual labels:  basic-authentication
horse-basic-auth
Middleware for Basic Authentication in HORSE
Stars: ✭ 37 (+164.29%)
Mutual labels:  basic-authentication
kave
Kemal API Version Extension
Stars: ✭ 31 (+121.43%)
Mutual labels:  kemal
SpringSecurityInEasySteps
Learn Spring Security step by step
Stars: ✭ 13 (-7.14%)
Mutual labels:  basic-authentication
Helmet
🐺 A Lightweight Cloud Native API Gateway.
Stars: ✭ 124 (+785.71%)
Mutual labels:  basic-authentication
kemal-rest-api
Crystal library to create REST API with Kemal
Stars: ✭ 56 (+300%)
Mutual labels:  kemal
kemal-vue-chat
this is experimental repo for Kemal and Vue.js (+ WebSocket)
Stars: ✭ 32 (+128.57%)
Mutual labels:  kemal
bedrock-site-protect
Ansible role: Add htpasswd protection to Trellis (Bedrock-Ansible) WordPress sites.
Stars: ✭ 79 (+464.29%)
Mutual labels:  basic-authentication
spec-kemal
Easy testing for Kemal
Stars: ✭ 51 (+264.29%)
Mutual labels:  kemal
static-auth
The most simple way to add Basic Authentication to a static website hosted on Vercel.
Stars: ✭ 25 (+78.57%)
Mutual labels:  basic-authentication
Kemal
Fast, Effective, Simple Web Framework
Stars: ✭ 3,227 (+22950%)
Mutual labels:  kemal
kemal-session
Simple session handler for Kemal
Stars: ✭ 47 (+235.71%)
Mutual labels:  kemal
crystular
Crystal regex tester http://www.crystular.org/
Stars: ✭ 31 (+121.43%)
Mutual labels:  kemal
Go Http Tunnel
Fast and secure tunnels over HTTP/2
Stars: ✭ 2,786 (+19800%)
Mutual labels:  basic-authentication
aws-lambda-edge-basic-auth-terraform
A Terraform module that creates AWS Lambda@Edge resources to protect CloudFront distributions with Basic Authentication.
Stars: ✭ 18 (+28.57%)
Mutual labels:  basic-authentication
http-authentication
PSR-15 middleware to implement Basic and Digest Http authentication
Stars: ✭ 29 (+107.14%)
Mutual labels:  basic-authentication
speedment-secure-rest-example
An example project showcasing how to build a secure REST API with Speedment and Spring Boot.
Stars: ✭ 17 (+21.43%)
Mutual labels:  basic-authentication

kemal-basic-auth

Add basic auth to your Kemal application.

Installation

Add this to your application's shard.yml:

dependencies:
  kemal-basic-auth:
    github: kemalcr/kemal-basic-auth

Usage

Basic example

kemal-basic-auth adds authentication to all routes by default.

require "kemal-basic-auth"

basic_auth "username", "password"
# basic_auth {"username1" => "password1", "username2" => "password2"}

Authentication for specific routes

Kemal::BasicAuth::Handler inherits from Kemal::Handler and it is therefore easy to create a custom handler that adds authentication to specific routes instead of all routes.

class CustomAuthHandler < Kemal::BasicAuth::Handler
  only ["/dashboard", "/admin"]

  def call(context)
    return call_next(context) unless only_match?(context)
    super
  end
end

Now just set Kemal.config.auth_handler = CustomAuthHandler and you are good to go.

kemal_authorized_username

HTTP::Server::Context#kemal_authorized_username? is set when the user is authorized.

basic_auth {"guest" => "123", "admin" => "xyz"}

get "/" do |env|
  "Hi, %s!" % env.kemal_authorized_username?
end

Contributing

  1. Fork it ( https://github.com/kemalcr/kemal-basic-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

  • sdogruyol Serdar Dogruyol - creator, maintainer
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].