gin_auth

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 5, 2022 License: MIT Imports: 10 Imported by: 0

README

gin-auth

Provides easy to use integration of github.com/go-pkgz/auth and gin-gonic/gin.

Usage

import (
	"github.com/katomaso/gin-auth"
)

func main() {
	router := gin.Default()
	auth := gin_auth.Basic("localhost:8080", "my-app-name", "secret")

	// this needs to be publicaly accessible
	router.Use(auth.Optional())
	router.GET("/auth", auth.AuthHandler())
	router.GET("/avatar", auth.AvatarHandler())

	// after using this middleware, all router will be for authorized users only
	router.Use(auth.Required())
	router.GET("/private", onlyForAuthenticatedUsers)
}

If the user is logged in, you will find c.Get("user") populated with value of go-pkgz/auth/token.User

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	*auth.Service
}

func Basic

func Basic(url, appName, secret string) Service

func (*Service) AuthHandler

func (s *Service) AuthHandler() gin.HandlerFunc

func (*Service) AvatarHandler

func (s *Service) AvatarHandler() gin.HandlerFunc

func (*Service) Optional

func (s *Service) Optional() gin.HandlerFunc

func (*Service) Required

func (s *Service) Required() gin.HandlerFunc

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL