auth

package
v0.0.0-...-93dcb33 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ProviderTypeSecret = "secret"
	ProviderTypeSAML   = "saml"
	ProviderTypeOIDC   = "oidc"

	HMAC_SHA2_256 = "hmac-sha2-256"
)
View Source
const (
	RoleUploadOnly    = "Upload-Only"
	RoleReadOnly      = "Read-Only"
	RoleAuditor       = "Auditor"
	RoleUser          = "User"
	RolePowerUser     = "Power User"
	RoleAdministrator = "Administrator"
)
View Source
const (
	RSASHA256SignatureMethod = "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
)

Variables

View Source
var (
	ErrInvalidOTP = fmt.Errorf("invalid one time password")
)

Functions

func GenerateQRCodeBase64

func GenerateQRCodeBase64(key otp.Key) (string, error)

func GenerateTOTPSecret

func GenerateTOTPSecret(issuer, accountName string) (*otp.Key, error)

func GetAssertionConsumerServiceURL

func GetAssertionConsumerServiceURL(metadata *saml.EntityDescriptor, bindingType string) (string, error)

GetAssertionConsumerServiceURL This may not be present, we return the first we find

func GetIDPSingleSignOnServiceURL

func GetIDPSingleSignOnServiceURL(metadata *saml.EntityDescriptor, bindingType string) (string, error)

func GetUserFromAuthCtx

func GetUserFromAuthCtx(ctx Context) (model.User, bool)

func NewServiceProvider

func NewServiceProvider(hostUrl url.URL, cfg config.Configuration, samlProvider model.SAMLProvider) (saml.ServiceProvider, error)

func NewUserAuthToken

func NewUserAuthToken(ownerId string, tokenName string, hmacMethod string, createdById uuid.UUID) (model.AuthToken, error)

NewUserAuthToken creates a new User model.AuthToken using the details provided

This isn't an ideal location for this function but it was determined to be the best place "for now". See https://specterops.atlassian.net/browse/BED-3367

func Roles

func Roles() map[string]RoleTemplate

Roles Note: Not the source of truth, changes here must be added to a migration *.sql file to update the roles & roles_permissions table

func ValidateTOTPSecret

func ValidateTOTPSecret(otp string, secret model.AuthSecret) error

Types

type AuditLogger

type AuditLogger interface {
	AppendAuditLog(ctx context.Context, entry model.AuditEntry) error
}

type Authorizer

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

func NewAuthorizer

func NewAuthorizer(auditLogger AuditLogger) Authorizer

func NewCustomAuthorizer

func NewCustomAuthorizer(auditLogger AuditLogger, getPermissionsFn GetPermissionsFunc) Authorizer

func (Authorizer) AllowsAllPermissions

func (s Authorizer) AllowsAllPermissions(ctx Context, requiredPermissions model.Permissions) bool

func (Authorizer) AllowsAtLeastOnePermission

func (s Authorizer) AllowsAtLeastOnePermission(ctx Context, requiredPermissions model.Permissions) bool

func (Authorizer) AllowsPermission

func (s Authorizer) AllowsPermission(ctx Context, requiredPermission model.Permission) bool

func (Authorizer) AuditLogUnauthorizedAccess

func (s Authorizer) AuditLogUnauthorizedAccess(request *http.Request)

type Context

type Context struct {
	PermissionOverrides PermissionOverrides
	Owner               any
	Session             model.UserSession
}

func (Context) Authenticated

func (s Context) Authenticated() bool

type GetPermissionsFunc

type GetPermissionsFunc func(context Context) (model.Permissions, bool)

type IdentityResolver

type IdentityResolver interface {
	GetIdentity(ctx Context) (SimpleIdentity, error)
}

func NewIdentityResolver

func NewIdentityResolver() IdentityResolver

type PermissionOverrides

type PermissionOverrides struct {
	Enabled     bool
	Permissions model.Permissions
}

type PermissionSet

type PermissionSet struct {
	AlertsRead   model.Permission
	AlertsManage model.Permission

	AppReadApplicationConfiguration  model.Permission
	AppWriteApplicationConfiguration model.Permission

	APsGenerateReport model.Permission
	APsManageAPs      model.Permission

	AuditLogRead model.Permission

	AuthAcceptEULA       model.Permission
	AuthCreateToken      model.Permission
	AuthReadProviders    model.Permission
	AuthManageProviders  model.Permission
	AuthManageSelf       model.Permission
	AuthManageUsers      model.Permission
	AuthReadUsers        model.Permission
	AuthReadUsersMinimal model.Permission

	ClientsManage  model.Permission
	ClientsRead    model.Permission
	ClientsTasking model.Permission

	CollectionReadJobs   model.Permission
	CollectionManageJobs model.Permission

	GraphDBIngestManage model.Permission
	GraphDBIngestRead   model.Permission
	GraphDBMutate       model.Permission
	GraphDBRead         model.Permission
	GraphDBWrite        model.Permission

	OpenGraphRead  model.Permission
	OpenGraphWrite model.Permission

	SavedQueriesRead  model.Permission
	SavedQueriesWrite model.Permission

	WipeDB model.Permission
}

func Permissions

func Permissions() PermissionSet

Permissions Note: Not the only source of truth, changes here must be added to a migration *.sql file to update the permissions table

func (PermissionSet) All

func (PermissionSet) ReadAll

func (s PermissionSet) ReadAll() model.Permissions

type RoleTemplate

type RoleTemplate struct {
	Name        string
	Description string
	Permissions model.Permissions
}

type SimpleIdentity

type SimpleIdentity struct {
	ID    uuid.UUID
	Name  string
	Email string
	Key   string
}

Jump to

Keyboard shortcuts

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