auth

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

internal/auth/auth.go

internal/auth/credentials.go

internal/auth/users.go

Index

Constants

This section is empty.

Variables

View Source
var ErrPrivilegeUpdateForbidden = errors.New("privilege updates require superuser privileges")

Functions

func ChangeUserPassword added in v0.1.4

func ChangeUserPassword(username, currentPassword, newPassword string, isSuperuser bool) error

ChangeUserPassword changes a user's password

func CreateUser added in v0.1.4

func CreateUser(req models.UserCreateRequest) error

CreateUser creates a new Linux user with the specified details

func DeleteUser added in v0.1.4

func DeleteUser(username string) error

DeleteUser deletes the specified user from the system

func GenerateJWT

func GenerateJWT(username string, expiresIn time.Duration) (string, error)

GenerateJWT creates a new JWT for a given username and expiration duration.

func GetAllUsers added in v0.1.4

func GetAllUsers() ([]models.UserDetails, error)

GetAllUsers returns a list of all system users that are relevant to the API Filters out system accounts or other internal users by their UID ranges

func GetUserDetails added in v0.1.4

func GetUserDetails(username string) (models.UserDetails, error)

GetUserDetails retrieves detailed information about a specific user

func InitAuth added in v0.1.5

func InitAuth()

InitAuth initializes the auth package with the current server start time

func IsUserInGroup

func IsUserInGroup(username string, targetGroupName string) (bool, error)

IsUserInGroup checks if a Linux user is a member of a specific group. Returns false, nil if the group doesn't exist or the user isn't in it. Returns false, error for actual system errors during lookup.

func ResolveLoginDuration added in v0.3.0

func ResolveLoginDuration(requested string, defaultDuration time.Duration) (time.Duration, error)

ResolveLoginDuration validates an optional login duration string and returns the effective JWT lifetime for the newly issued token.

func UpdateUser added in v0.1.4

func UpdateUser(username string, req models.UserUpdateRequest, allowPrivilegeUpdate bool) error

UpdateUser updates the specified user's information.

func ValidateCredentials

func ValidateCredentials(username, password string) (bool, error)

ValidateCredentials checks if the Linux user exists, validates the password using PAM, and verifies membership in EITHER the requiredAdminGroup OR the configured APIUserGroup.

Types

type Claims

type Claims struct {
	Username string `json:"username"`
	jwt.RegisteredClaims
}

func ValidateJWT

func ValidateJWT(tokenString string) (*Claims, error)

ValidateJWT checks the validity of a JWT string

Jump to

Keyboard shortcuts

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