auth

package module
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 11 Imported by: 0

README

Auth Module

Install

go get github.com/aruncs31s/esdcauthmodule

Usage

package main

import "github.com/aruncs31s/esdcauthmodule"

func main() {
	r := gin.Default()
	db, err := gorm.Open(sqlite.Open("db.db"), &gorm.Config{})
	if err != nil {
		panic("failed to connect database")
	}
	if err := db.AutoMigrate(model.User{}); err != nil {
		log.Fatal("Failed to migrate database:", err)
	}
	if err := db.AutoMigrate(model.Github{}); err != nil {
		log.Fatal("Failed to migrate database:", err)
	}
	auth.InitAuthModule(r, db)
	r.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddAZFAuthMiddleware added in v0.5.5

func AddAZFAuthMiddleware(r *gin.Engine)

AddAZFAuthMiddleware adds AZF authorization middleware Enforces Casbin-based RBAC policies

Params:

  • r: Gin engine instance

func AddAZFTrackingMiddleware added in v0.5.5

func AddAZFTrackingMiddleware(r *gin.Engine)

AddAZFTrackingMiddleware adds API usage tracking middleware Tracks endpoint usage, response times, and other metrics

Params:

  • r: Gin engine instance

func AddJWTMiddleware added in v0.3.0

func AddJWTMiddleware(r *gin.Engine)

AddJWTMiddleware adds the JWT middleware to the Gin engine

Params:

  • r: Gin engine instance

func InitAZFModule added in v0.5.5

func InitAZFModule(db *gorm.DB, enforcer *casbin.Enforcer)

InitAZFModule initializes the AZF Authorization Framework This sets up Casbin-based RBAC authorization

Params:

  • db: GORM database instance (optional, can be nil)
  • enforcer: Casbin enforcer instance (optional, can be nil)

func InitAZFUsageTracking added in v0.5.5

func InitAZFUsageTracking()

InitAZFUsageTracking initializes API usage tracking Call this after InitAZFModule

func InitAuthModule

func InitAuthModule(r *gin.Engine, db *gorm.DB)

InitAuthModule initializes the authentication module

Params:

  • r: Gin engine instance
  • db: GORM database instance

func InitFullAZF added in v0.5.5

func InitFullAZF(r *gin.Engine, db *gorm.DB, enforcer *casbin.Enforcer)

InitFullAZF is a convenience function that initializes all AZF components This includes: authorization module, usage tracking, tracking middleware, authorization middleware, and admin UI

Params:

  • r: Gin engine instance
  • db: GORM database instance (optional, can be nil)
  • enforcer: Casbin enforcer instance (optional, can be nil)

func SetupAZFDocs added in v0.5.5

func SetupAZFDocs(r *gin.Engine, docsPath string)

SetupAZFDocs sets up documentation routes

Params:

  • r: Gin engine instance
  • docsPath: Path to the documentation directory

func SetupAZFUI added in v0.5.5

func SetupAZFUI(r *gin.Engine)

SetupAZFUI sets up the AZF admin UI Provides web interface for policy management and analytics

Params:

  • r: Gin engine instance

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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