handlers

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package handlers defines a generic interface for authentication mechanisms.

This package provides the core contracts (interfaces and data structures) for handling different authentication strategies. The main component is the AuthHandler interface, which must be implemented by any concrete authentication method, such as STS (Security Token Service), LDAP, or any other identity provider.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandler

type AuthHandler interface {
	// Authenticate validates the credential and returns the [Principal] (identity)
	// in case of success, or an error otherwise.
	Authenticate(ctx context.Context) (*Principal, error)
}

AuthHandler is the interface that defines the contract for an authentication mechanism. Each implementation is responsible for validating a specific type of credential.

type Credential

type Credential struct {
	ClientID     string `json:"client_id"`
	ClientSecret string `json:"client_secret"`
}

Credential represents the authentication keys that will be used to perform the system, application or user authentication.

type Options

type Options struct {
	InsecureSkipVerify bool `json:"insecureSkipVerify"`
}

Options contains the optional attributes that can be used to customize the authentication process.

type Principal

type Principal struct {
	ID          string                 `json:"id"`
	Roles       []string               `json:"roles"`
	Scopes      []string               `json:"scopes"`
	Extra       map[string]interface{} `json:"extra"`
	AccessToken *string                `json:"accessToken"`
	ExpiresAt   time.Time              `json:"expiresAt"`
}

Principal represents the authenticated identity. It may contain information such as user ID, Scopes, Roles, Token, etc.

type STSAuthHandler

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

STSAuthHandler implementa AuthHandler para validar tokens JWT.

func NewSTSAuthHandler

func NewSTSAuthHandler(tokenServiceUrl string, credential *Credential, options *Options) *STSAuthHandler

NewSTSAuthHandler creates a new AuthHandler for a Security Token Service (STS).

func (*STSAuthHandler) Authenticate

func (h *STSAuthHandler) Authenticate(ctx context.Context) (*Principal, error)

Authenticate performs the authentication of credentials and obtains the access token generated by the Security Token Service (STS)

Jump to

Keyboard shortcuts

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