Documentation
¶
Overview ¶
Package user handles all the user-related logic
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticate ¶
Authenticate a user using the provided parameters
Example ¶
manager, err := NewAuthManager("[email protected]", "token", mockb(fca, fcert, addrPort)) if err != nil { fmt.Println(err.Error()) } fmt.Println("Manager successfully created") err = manager.Authenticate() if err != nil { fmt.Println(err.Error()) } fmt.Println("Manager said authentication went fine") if b := common.FileExists(fcert); !b { fmt.Println("The cert file was not saved to disk") } else { fmt.Println("The cert file was saved to disk") _ = os.Remove(fcert) }
Output: Manager successfully created Manager said authentication went fine The cert file was saved to disk
func Unregister ¶ added in v0.3.0
Unregister a user from the platform
Types ¶
type AuthManager ¶
type AuthManager struct {
// contains filtered or unexported fields
}
AuthManager handles the authentication of a user
func NewAuthManager ¶
func NewAuthManager(mail, token string, viper *viper.Viper) (*AuthManager, error)
NewAuthManager creates a new authentication manager with the given parameters
func (*AuthManager) Authenticate ¶
func (m *AuthManager) Authenticate() error
Authenticate performs the authentication request (ie connection to the platform grpc server, sending of the request, handling the response)
type Config ¶
type Config struct { KeyFile string `json:"key"` KeyData []byte `json:"keyData"` CertFile string `json:"cert"` CertData []byte `json:"certData"` }
Config represents the config file to be marshalled in json
func DecodeConfiguration ¶
DecodeConfiguration : decrypt and unmarshal the given configuration file to create a Config object. It also checks the validity of the certificate and private key
func NewConfig ¶
NewConfig creates a new config object from the key and certificate provided The validity of those is checked later
func (*Config) SaveConfigToFile ¶
SaveConfigToFile marshals checks the validity of the certificate and private key, marshals the struct in JSON, encrypt the string using AES-256 with the provided passphrase, and finally save it to a file
func (*Config) SaveUserInformations ¶
SaveUserInformations save the certificate and private key to the files specified in the Config struct
type RegisterManager ¶
RegisterManager handles the registration of a user
func NewRegisterManager ¶
func NewRegisterManager(passphrase, country, organization, unit, mail string, bits int, v *viper.Viper) (*RegisterManager, error)
NewRegisterManager return a new Register Manager to register a user
func (*RegisterManager) GetCertificate ¶
func (m *RegisterManager) GetCertificate() error
GetCertificate handles the creation of a certificate, delete private key upon failure