user

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2016 License: MIT Imports: 14 Imported by: 0

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

func Authenticate(mail, token string) error

Authenticate a user using the provided parameters

Example
manager, err := NewAuthManager("mail@mail.mail", "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 Register

func Register(passphrase, country, organization, unit, mail string, bits int) error

Register a user using the provided parameters

func Unregister added in v0.3.0

func Unregister(passphrase string) error

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

func DecodeConfiguration(fileName, keyPassphrase, confPassphrase string) (*Config, error)

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

func NewConfig(viper *viper.Viper) (*Config, error)

NewConfig creates a new config object from the key and certificate provided The validity of those is checked later

func (*Config) SaveConfigToFile

func (c *Config) SaveConfigToFile(fileName, passphrase, keyPassphrase string) error

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

func (c *Config) SaveUserInformations() error

SaveUserInformations save the certificate and private key to the files specified in the Config struct

type RegisterManager

type RegisterManager struct {
	*viper.Viper
	// contains filtered or unexported fields
}

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

Jump to

Keyboard shortcuts

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