authproviders

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Copyright © 2024 Alexandre Pires

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUser

func AddUser(username, password string) error

func AuthenticateUser

func AuthenticateUser(username, password string) bool

func ChangePassword

func ChangePassword(username, password string) error

func DropUsers

func DropUsers() error

func GetUsers

func GetUsers() ([]string, error)

func HashPassword

func HashPassword(password string) string

func InitializeAuthProvider

func InitializeAuthProvider(provider string, config json.RawMessage) error

func RemoveUser

func RemoveUser(username string) error

func SetAuthProviderFactory

func SetAuthProviderFactory(factory AuthProviderFactory, config json.RawMessage)

Types

type AuthProvider

type AuthProvider interface {
	AuthenticateUser(username, password string) bool
	AddUser(username, password string) error
	RemoveUser(username string) error
	GetUsers() ([]string, error)
	ChangePassword(username, password string) error
	DropUsers() error
	LoadUsers() error
}

func GetAuthProvider

func GetAuthProvider() AuthProvider

func NewFileAuthProvider

func NewFileAuthProvider(config json.RawMessage) AuthProvider

func NewMemoryAuthProvider

func NewMemoryAuthProvider(config json.RawMessage) AuthProvider

func NewNullAuthProvider

func NewNullAuthProvider(config json.RawMessage) AuthProvider

type AuthProviderFactory

type AuthProviderFactory func(config json.RawMessage) AuthProvider

type FileAuthProvider

type FileAuthProvider struct {
	AuthProvider
	// contains filtered or unexported fields
}

func (*FileAuthProvider) AddUser

func (a *FileAuthProvider) AddUser(username, password string) error

func (*FileAuthProvider) AuthenticateUser

func (a *FileAuthProvider) AuthenticateUser(username, password string) bool

func (*FileAuthProvider) ChangePassword

func (a *FileAuthProvider) ChangePassword(username, password string) error

func (*FileAuthProvider) DropUsers

func (a *FileAuthProvider) DropUsers() error

func (*FileAuthProvider) GetUsers

func (a *FileAuthProvider) GetUsers() ([]string, error)

func (*FileAuthProvider) LoadUsers

func (a *FileAuthProvider) LoadUsers() error

func (*FileAuthProvider) RemoveUser

func (a *FileAuthProvider) RemoveUser(username string) error

type FileAuthProviderConfig

type FileAuthProviderConfig struct {
	FilePath string `json:"file_path"`
}

type MemoryAuthProvide

type MemoryAuthProvide struct {
	AuthProvider
	// contains filtered or unexported fields
}

func (*MemoryAuthProvide) AddUser

func (a *MemoryAuthProvide) AddUser(username, password string) error

func (*MemoryAuthProvide) AuthenticateUser

func (a *MemoryAuthProvide) AuthenticateUser(username, password string) bool

func (*MemoryAuthProvide) ChangePassword

func (a *MemoryAuthProvide) ChangePassword(username, password string) error

func (*MemoryAuthProvide) DropUsers

func (a *MemoryAuthProvide) DropUsers() error

func (*MemoryAuthProvide) GetUsers

func (a *MemoryAuthProvide) GetUsers() ([]string, error)

func (*MemoryAuthProvide) LoadUsers

func (a *MemoryAuthProvide) LoadUsers() error

func (*MemoryAuthProvide) RemoveUser

func (a *MemoryAuthProvide) RemoveUser(username string) error

type NullAuthProvider

type NullAuthProvider struct {
	AuthProvider
}

func (*NullAuthProvider) AddUser

func (a *NullAuthProvider) AddUser(username, password string) error

func (*NullAuthProvider) AuthenticateUser

func (a *NullAuthProvider) AuthenticateUser(username, password string) bool

func (*NullAuthProvider) ChangePassword

func (a *NullAuthProvider) ChangePassword(username, password string) error

func (*NullAuthProvider) DropUsers

func (a *NullAuthProvider) DropUsers() error

func (*NullAuthProvider) GetUsers

func (a *NullAuthProvider) GetUsers() ([]string, error)

func (*NullAuthProvider) LoadUsers

func (a *NullAuthProvider) LoadUsers() error

func (*NullAuthProvider) RemoveUser

func (a *NullAuthProvider) RemoveUser(username string) error

type User

type User struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type Users

type Users struct {
	Users []User `json:"users"`
}

Jump to

Keyboard shortcuts

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