Documentation ¶
Index ¶
Constants ¶
const ( EnvLocalConfigPath = "AUTH_SERVER_LOCAL_CONFIG_PATH" DefaultLocalConfigPath = "../../config/local_repository_config.yml" )
Variables ¶
This section is empty.
Functions ¶
func HashAndSalt ¶
Types ¶
type AerospikeRepository ¶
type AerospikeRepository struct {
// contains filtered or unexported fields
}
AerospikeRepository implements the Repository interface using Aerospike Database as the storage backend.
func NewAerospike ¶
func NewAerospike() (*AerospikeRepository, error)
NewAerospike returns a new AerospikeRepository using environment variables for configuration.
func (*AerospikeRepository) AuthenticateBasic ¶
func (aero *AerospikeRepository) AuthenticateBasic(username string, password string) *UserDetails
AuthenticateBasic validates the basic username and password before issuing a JWT. It uses the bcrypt password-hashing function to validate the password.
func (*AerospikeRepository) AuthorizeRequest ¶
func (aero *AerospikeRepository) AuthorizeRequest(userRole UserRole, request RequestDetails) bool
AuthorizeRequest checks if the role has permissions to access the endpoint.
type AuthDetails ¶
AuthDetails contains authentication details for the user.
type Local ¶
type Local struct { Users map[string]AuthDetails `yaml:"users"` Roles map[UserRole][]RequestDetails `yaml:"roles"` }
Local implements the Repository interface by loading authentication details from a local configuration file.
func NewLocal ¶
NewLocal returns a new Local repository using an environment variable to read a custom path to the configuration file.
func (*Local) AuthenticateBasic ¶
func (local *Local) AuthenticateBasic(username string, password string) *UserDetails
AuthenticateBasic validates the basic username and password before issuing a JWT.
func (*Local) AuthorizeRequest ¶
func (local *Local) AuthorizeRequest(userRole UserRole, requestDetails RequestDetails) bool
AuthorizeRequest checks if the role has permissions to access the endpoint.
type Repository ¶
type Repository interface { // AuthenticateBasic validates the basic username and password before issuing a JWT. AuthenticateBasic(username string, password string) *UserDetails // AuthorizeRequest checks if the role has permissions to access the endpoint. AuthorizeRequest(userRole UserRole, request RequestDetails) bool }
A Repository acts as a gateway to the authentication and authorization operations, facilitating secure access to resources.
type RequestDetails ¶
RequestDetails represents request details.
func (RequestDetails) String ¶
func (r RequestDetails) String() string
String implements the fmt.Stringer interface.
type UserDetails ¶
UserDetails represents user details.
type VaultRepository ¶
type VaultRepository struct {
// contains filtered or unexported fields
}
VaultRepository implements the Repository interface using HashiCorp Vault as the storage backend.
func NewVault ¶
func NewVault() (*VaultRepository, error)
NewVault returns a new VaultRepository using environment variables for configuration.
func (*VaultRepository) AuthenticateBasic ¶
func (vr *VaultRepository) AuthenticateBasic(username string, password string) *UserDetails
AuthenticateBasic validates the basic username and password before issuing a JWT. It uses the bcrypt password-hashing function to validate the password.
func (*VaultRepository) AuthorizeRequest ¶
func (vr *VaultRepository) AuthorizeRequest(userRole UserRole, request RequestDetails) bool
AuthorizeRequest checks if the role has permissions to access the endpoint.