fiber api key authentication middleware

Overview

fiber-key-auth

Secure your fiber endpoints using API keys.
Report Bug · Request Feature

Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact

About The Project

On deployment inject API keys authorized to use your service. Every call to a private endpoint of your service has to include a header['x-api-key'] attribute that is validated against the API keys (starting with: API_KEY_) in your environment. If it is present, a request is authorized. If it is not fiber returns 401 Unauthorized. Use this either as a middleware the usage.

Built With

Getting Started

Installation

go get github.com/iwpnd/fiber-key-auth

Usage

As Middleware:

package main

import (
	"os"

	"github.com/iwpnd/fiber-key-auth"
	"github.com/gofiber/fiber/v2"
	)

os.Setenv("API_KEY_TEST", "valid")

func main() {
    app := fiber.New()

    app.Use(keyauth.New())

    app.Get("/", func(c *fiber.Ctx) error {
        return c.SendString("Hello, World 👋!")
    })

    app.Listen(":3000")
}

Now try to access your / route.

> "invalid api key" curl localhost:3000 -H "x-api-key: valid" >> Hello, World 👋! ">
curl localhost:3000

>> "no api key"

curl localhost:3000 -H "x-api-key: invalid"

>> "invalid api key"

curl localhost:3000 -H "x-api-key: valid"

>> Hello, World 👋!

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Benjamin Ramser - @imwithpanda - [email protected]
Project Link: https://github.com/iwpnd/fiber-key-auth

Releases(v0.1.0)
  • v0.1.0(Oct 2, 2021)

    About The Project

    On deployment inject API keys authorized to use your service. Every call to a private endpoint of your service has to include a header['x-api-key'] attribute that is validated against the API keys (starting with: API_KEY_) in your environment. If it is present, a request is authorized. If it is not fiber returns 401 Unauthorized. Use this either as a middleware the usage.

    Built With

    Getting Started

    Installation

    go get github.com/iwpnd/fiber-key-auth
    

    Usage

    As Middleware:

    package main
    
    import (
    	"os"
    
    	"github.com/iwpnd/fiber-key-auth"
    	"github.com/gofiber/fiber/v2"
    	)
    
    os.Setenv("API_KEY_TEST", "valid")
    
    func main() {
        app := fiber.New()
    
        app.Use(keyauth.New())
    
        app.Get("/", func(c *fiber.Ctx) error {
            return c.SendString("Hello, World 👋 !")
        })
    
        app.Listen(":3000")
    }
    

    Now try to access your / route.

    curl localhost:3000
    
    >> "no api key"
    
    curl localhost:3000 -H "x-api-key: invalid"
    
    >> "invalid api key"
    
    curl localhost:3000 -H "x-api-key: valid"
    
    >> "Hello, World 👋 !"
    

    License

    Distributed under the MIT License. See LICENSE for more information.

    Contact

    Benjamin Ramser - @imwithpanda - [email protected]
    Project Link: https://github.com/iwpnd/fiber-key-auth

    Source code(tar.gz)
    Source code(zip)
Owner
Ben
geographer turned spatial engineer turned data-something turned software developer
Ben
A simple passwordless proxy authentication middleware using email.

email proxy auth A simple passwordless proxy authentication middleware that uses only email as the authentication provider. Motivation I wanted to res

Miroslav Šedivý 5 Jul 27, 2022
Authelia: an open-source authentication and authorization server providing two-factor authentication

Authelia is an open-source authentication and authorization server providing two

Streato 0 Jan 5, 2022
Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Authentication Plugin for implementing Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0, SAML Authentication

Paul Greenberg 490 Aug 8, 2022
Authorization and authentication. Learning go by writing a simple authentication and authorization service.

Authorization and authentication. Learning go by writing a simple authentication and authorization service.

Dinesh Bhattarai 0 Aug 5, 2022
Key-Checker - Go scripts for checking API key / access token validity

Key-Checker Go scripts for checking API key / access token validity Update V1.0.0 ?? Added 37 checkers! Screenshoot ?? How to Install go get github.co

Muhammad Daffa 190 Jul 20, 2022
stark key authentication library, signature generator for dydx exchange

stark key authentication library, signature generator for dydx exchange for the following operations: Place an order Withdraw funds link : https://doc

null 10 Aug 10, 2022
Golang based User creation and Management application. GORM, Fiber, JWT

User Creation and Management app (BACK-END) Auth Features: Create Clients (regular password + 6 one-time passwords + (optional) QR code and Secret for

Artūras 5 May 11, 2022
Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to create powerful modern API and web authentication.

❗ Cache package has been moved to libcache repository Go-Guardian Go-Guardian is a golang library that provides a simple, clean, and idiomatic way to

Sanad Haj Yahya 389 Aug 3, 2022
🔥 Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

?? Golang Rest Api with basic JWT Authentication and Basic Crud Operations.

Junaid Javed 16 Jul 29, 2022
This package provides json web token (jwt) middleware for goLang http servers

jwt-auth jwt auth middleware in goLang. If you're interested in using sessions, checkout my sessions library! README Contents: Quickstart Performance

Adam Hanna 218 Jul 29, 2022
:closed_lock_with_key: Middleware for keeping track of users, login states and permissions

Permissions2 Middleware for keeping track of users, login states and permissions. Online API Documentation godoc.org Features and limitations Uses sec

Alexander F. Rødseth 460 Aug 5, 2022
A dead simple, highly performant, highly customizable sessions middleware for go http servers.

If you're interested in jwt's, see my jwt library! Sessions A dead simple, highly performant, highly customizable sessions service for go http servers

Adam Hanna 66 Jul 25, 2022
fastglue-csrf implements CSRF middleware for fastglue.

fastglue-csrf Overview fastglue-csrf implements CSRF middleware for fastglue.

Joe Paul 13 Jan 5, 2022
ACL, RBAC, ABAC authorization middleware for KubeSphere

casbin-kubesphere-auth Casbin-kubesphere-auth is a plugin which apply several security authentication check on kubesphere via casbin. This plugin supp

Casbin 4 Jun 9, 2022
OAuth 2.0 middleware service for chi (ported from gin by community member)

oauth middleware OAuth 2.0 Authorization Server & Authorization Middleware for go-chi This library was ported to go-chi from https://github.com/maxzer

go-chi 14 Jul 7, 2022
Auth Middleware for session & white-listed routing

Auth Middleware for session & white-listed routing

Joe Gasewicz 2 Nov 4, 2021
JWT and Permission Middleware with MongoRPC

JWT and Permission Middleware with MongoRPC

mongorpc 1 Nov 19, 2021
:key: Secure alternative to JWT. Authenticated Encrypted API Tokens for Go.

branca branca is a secure alternative to JWT, This implementation is written in pure Go (no cgo dependencies) and implements the branca token specific

Wesley Hill 168 Aug 7, 2022
Go login handlers for authentication providers (OAuth1, OAuth2)

gologin Package gologin provides chainable login http.Handler's for Google, Github, Twitter, Facebook, Bitbucket, Tumblr, or any OAuth1 or OAuth2 auth

Dalton Hubble 1.5k Aug 13, 2022