utils

package
v0.0.0-...-6371a9c Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authenticate

func Authenticate(next http.Handler) http.Handler

func CheckPolicyPermission

func CheckPolicyPermission(policies []models.Policy, identity Identity, path string, action string) bool

func Contains

func Contains(slice []string, item string) bool

Contains checks if a slice contains a specific string.

func ConvertCertificateToPEM

func ConvertCertificateToPEM(certDER []byte) string

ConvertCertificateToPEM converts a DER encoded certificate to PEM format

func ConvertPrivateKeyToPEM

func ConvertPrivateKeyToPEM(privateKey interface{}) (string, error)

ConvertPrivateKeyToPEM converts a private key to PEM format

func DecryptSecretValue

func DecryptSecretValue(secret models.Secret) (string, error)

func EncryptSecretValue

func EncryptSecretValue(input string) ([]byte, []byte, error)

func GeneratePassword

func GeneratePassword() string

func GenerateUsername

func GenerateUsername() string

func MatchPath

func MatchPath(pattern, path string) bool

MatchPath checks if the given path matches the policy path pattern.

func ParseHCLPolicy

func ParseHCLPolicy(hclString string) (models.Policy, error)

func ScanForSecrets

func ScanForSecrets(text string) []string

ScanForSecrets scans the given text and returns potential secrets

func ToInt

func ToInt(i string) int

func ToInt64

func ToInt64(i string) int64

Types

type AppRoleIdentity

type AppRoleIdentity struct {
	AppRoleID int64
	RoleName  string
}

func (AppRoleIdentity) GetAuthType

func (a AppRoleIdentity) GetAuthType() string

func (AppRoleIdentity) GetID

func (a AppRoleIdentity) GetID() int64

func (AppRoleIdentity) GetUsername

func (a AppRoleIdentity) GetUsername() string

type Identity

type Identity interface {
	GetID() int64
	GetUsername() string
	GetAuthType() string
}

type UserIdentity

type UserIdentity struct {
	UserID   int64
	Username string
}

func (UserIdentity) GetAuthType

func (u UserIdentity) GetAuthType() string

func (UserIdentity) GetID

func (u UserIdentity) GetID() int64

func (UserIdentity) GetUsername

func (u UserIdentity) GetUsername() string

Jump to

Keyboard shortcuts

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