Categorygithub.com/martinreus/auth-middleware
modulepackage
0.0.5
Repository: https://github.com/martinreus/auth-middleware.git
Documentation: pkg.go.dev

# README

Auth services and Middleware for Go applications

How to use it

package main

import (
    "github.com/gorilla/mux"
    "github.com/martinreus/auth-middleware"
)

func main() {
    r := mux.NewRouter()
    authConfig := auth.DefaultConfig()
    authMiddleware := auth.NewService(authConfig)

    api := r.PathPrefix("/api").Subrouter()
    api.HandleFunc("/user/{id}", GetUser).Methods("GET")
    api.Use(authMiddleware.IsAuthenticated)

    http.ListenAndServe(":8000", r)
}

func GetUser(w http.ResponseWriter, r *http.Request) {...}

Each request will now need a valid JWT Token in order to access the get user route.

TODO:

Improve

this.doc()

:)

# Packages

No description provided by the author

# Functions

* Default values used: JWTCookieName: "JWT", TokenExpiresIn: 900, Issuer: "AuthServer", MaxRenewalTime: 2592000, */.
* Constructor for authService (which is the Service instantiation) */.
* Constructor for authService (which is the Service instantiation) */.

# Variables

No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

No description provided by the author