auth

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

AuthService handles authentication operations.

func NewAuthService

func NewAuthService(db *gorm.DB, cfg config.AuthConfig) *AuthService

NewAuthService creates an AuthService, seeds default credentials if needed, and syncs from the credentials file if present.

func (*AuthService) AuthMiddleware

func (s *AuthService) AuthMiddleware() gin.HandlerFunc

AuthMiddleware returns a Gin middleware that validates JWT tokens. It accepts tokens from the Authorization: Bearer header OR from the ?token= query parameter (required for WebSocket connections which cannot set custom headers from browsers).

func (*AuthService) Login

func (s *AuthService) Login(username, password string) (string, error)

Login validates credentials and returns a signed JWT valid for 24 hours.

Jump to

Keyboard shortcuts

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