Documentation ¶
Index ¶
- func CheckAuthIdentity(authValue string, validFor string) (identityTokenStruct, string, error)
- func CheckIdentity(nick, password, validFor string) (identityTokenStruct, error)
- func GenerateEntityToken() string
- func GenerateIdentityToken() string
- func GenerateNick() string
- func GeneratePassword(length int) string
- func GeneratePin() string
- func Hash(original string) string
- func Initialize(aDb DbInterface)
- func InitializeDirectory(folderPath string) error
- func IsAuthIdentityTokenValid(authValue string, validFor string) bool
- func IsAuthorized(token string, authLeaf AuthNodeStruct) bool
- func IsIdentityTokenValid(token string, validFor string) bool
- type AuthNodeStruct
- type ConfigurationStruct
- type DbFile
- func (m DbFile) DeleteContentsFromDirectory(dir string) error
- func (m DbFile) DeleteEntity(nick string) error
- func (m DbFile) DeleteEntityToken(token string) error
- func (m DbFile) EntityExists(nick string) bool
- func (m *DbFile) Initialize()
- func (m DbFile) ReadAuthNodes(authNodes *[]AuthNodeStruct) error
- func (m DbFile) ReadEntityByNick(nick string) (*Entity, error)
- func (m DbFile) ReadEntityList() (nicklist []string, e error)
- func (m DbFile) ReadEntityToken(token string) (*EntityToken, error)
- func (m DbFile) ReadPublicEntityByNick(nick string) (*PublicEntity, error)
- func (m DbFile) SaveAuthNodes(authNodes *[]AuthNodeStruct) error
- func (m DbFile) SaveEntity(e *Entity) error
- func (m DbFile) SaveEntityToken(et *EntityToken) error
- type DbInterface
- type DbTransient
- func (m DbTransient) DeleteEntity(nick string) error
- func (m DbTransient) DeleteEntityToken(token string) error
- func (m DbTransient) EntityExists(nick string) bool
- func (m *DbTransient) Initialize()
- func (m DbTransient) ReadAuthNodes(authNode *[]AuthNodeStruct) error
- func (m DbTransient) ReadEntityByNick(nick string) (*Entity, error)
- func (m DbTransient) ReadEntityList() (nicklist []string, e error)
- func (m DbTransient) ReadEntityToken(token string) (*EntityToken, error)
- func (m DbTransient) ReadPublicEntityByNick(nick string) (*PublicEntity, error)
- func (m DbTransient) SaveAuthNodes(authNode *[]AuthNodeStruct) error
- func (m DbTransient) SaveEntity(e *Entity) error
- func (m DbTransient) SaveEntityToken(et *EntityToken) error
- type Entity
- type EntityToken
- type NewEntityStruct
- type PublicEntity
- type ServerId
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckAuthIdentity ¶
CheckAuthIdentity checks nick and password and provides and identity token (for validFor) it also returns the nick, that was checked
func CheckIdentity ¶
CheckIdentity checks nick and password and provides and identity token (for validFor)
func GenerateEntityToken ¶
func GenerateEntityToken() string
GenerateEntityToken generates a valid entity token
func GenerateIdentityToken ¶
func GenerateIdentityToken() string
GenerateIdentityToken generates a identity token
func GeneratePassword ¶
GeneratePassword generates a password
func InitializeDirectory ¶ added in v0.0.3
InitializeDirectory checks if 'folderPath' exists and creates it, if it's not existing
func IsAuthIdentityTokenValid ¶
IsAuthIdentityTokenValid checks if the identity token is valid, validFor contains information about the client, e.g. the IP address
func IsAuthorized ¶ added in v0.0.3
func IsAuthorized(token string, authLeaf AuthNodeStruct) bool
IsAuthorized checks if the entity, provides through token, is authorizied for authLeaf
func IsIdentityTokenValid ¶
IsIdentityTokenValid checks if the identity token is valid, validFor contains information about the client, e.g. the IP address
Types ¶
type AuthNodeStruct ¶ added in v0.0.3
type ConfigurationStruct ¶
type ConfigurationStruct struct { ServerId string `json:"serverId"` Port string `json:"port"` EntityTokenValidityHours int `json:"entityTokenValidityHours"` IdentityTokenValiditySeconds int `json:"identityTokenValiditySeconds"` MaxSignInAttempts int `json:"maxSignInAttempts"` }
var Configuration ConfigurationStruct
type DbFile ¶
type DbFile struct { EntityFilePath string EntityDeletedFilePath string EntityTokenFilePath string AuthNodeFilePath string DBPath string }
DbFile - use the filesystem and store json files
func (DbFile) DeleteContentsFromDirectory ¶ added in v0.0.3
func (DbFile) DeleteEntity ¶ added in v0.0.16
func (DbFile) DeleteEntityToken ¶
func (DbFile) EntityExists ¶
func (*DbFile) Initialize ¶
func (m *DbFile) Initialize()
func (DbFile) ReadAuthNodes ¶ added in v0.0.3
func (m DbFile) ReadAuthNodes(authNodes *[]AuthNodeStruct) error
func (DbFile) ReadEntityList ¶ added in v0.0.10
func (DbFile) ReadEntityToken ¶
func (m DbFile) ReadEntityToken(token string) (*EntityToken, error)
func (DbFile) ReadPublicEntityByNick ¶ added in v0.0.17
func (m DbFile) ReadPublicEntityByNick(nick string) (*PublicEntity, error)
func (DbFile) SaveAuthNodes ¶ added in v0.0.3
func (m DbFile) SaveAuthNodes(authNodes *[]AuthNodeStruct) error
func (DbFile) SaveEntity ¶
func (DbFile) SaveEntityToken ¶
func (m DbFile) SaveEntityToken(et *EntityToken) error
type DbInterface ¶
type DbInterface interface { Initialize() // Entity ReadEntityList() (nicklist []string, e error) ReadEntityByNick(nick string) (*Entity, error) ReadPublicEntityByNick(nick string) (*PublicEntity, error) EntityExists(nick string) bool SaveEntity(entity *Entity) error DeleteEntity(nick string) error // Entity Tokens SaveEntityToken(entityToken *EntityToken) error ReadEntityToken(tokenoken string) (*EntityToken, error) DeleteEntityToken(token string) error // Auth Nodes ReadAuthNodes(authNode *[]AuthNodeStruct) error SaveAuthNodes(authNode *[]AuthNodeStruct) error }
var Db DbInterface
*******************************************************************
Interface Db (database, persistent storage)
*******************************************************************
type DbTransient ¶ added in v0.0.2
type DbTransient struct {
// contains filtered or unexported fields
}
DbTransient - non-persistent database for testing and demonstration
func (DbTransient) DeleteEntity ¶ added in v0.0.16
func (m DbTransient) DeleteEntity(nick string) error
func (DbTransient) DeleteEntityToken ¶ added in v0.0.2
func (m DbTransient) DeleteEntityToken(token string) error
func (DbTransient) EntityExists ¶ added in v0.0.2
func (m DbTransient) EntityExists(nick string) bool
func (*DbTransient) Initialize ¶ added in v0.0.2
func (m *DbTransient) Initialize()
func (DbTransient) ReadAuthNodes ¶ added in v0.0.3
func (m DbTransient) ReadAuthNodes(authNode *[]AuthNodeStruct) error
func (DbTransient) ReadEntityByNick ¶ added in v0.0.2
func (m DbTransient) ReadEntityByNick(nick string) (*Entity, error)
func (DbTransient) ReadEntityList ¶ added in v0.0.10
func (m DbTransient) ReadEntityList() (nicklist []string, e error)
func (DbTransient) ReadEntityToken ¶ added in v0.0.2
func (m DbTransient) ReadEntityToken(token string) (*EntityToken, error)
func (DbTransient) ReadPublicEntityByNick ¶ added in v0.0.17
func (m DbTransient) ReadPublicEntityByNick(nick string) (*PublicEntity, error)
func (DbTransient) SaveAuthNodes ¶ added in v0.0.3
func (m DbTransient) SaveAuthNodes(authNode *[]AuthNodeStruct) error
func (DbTransient) SaveEntity ¶ added in v0.0.2
func (m DbTransient) SaveEntity(e *Entity) error
func (DbTransient) SaveEntityToken ¶ added in v0.0.2
func (m DbTransient) SaveEntityToken(et *EntityToken) error
type Entity ¶
type Entity struct { Nick string `json:"nick"` PasswordHash string `json:"passwordHash"` SecretHash string `json:"secretHash"` Active bool `json:"active"` WrongPasswordCounter int `json:"WrongPasswordCounter"` LastSignInAttempt time.Time `json:"lastSignInAttempt"` LastSignIn time.Time `json:"lastSignIn"` CreateTimeStamp time.Time `json:"createTimeStamp"` UpdateTimeStamp time.Time `json:"updateTimeStamp"` }
Entity describes a user or a device
func (*Entity) ToPublicEntity ¶ added in v0.0.17
func (e *Entity) ToPublicEntity() PublicEntity
ToPublicEntity converts an EntityStruct to PublicEntity
type EntityToken ¶
type EntityToken struct { Token string `json:"token"` Pin string `json:"pin"` ValidUntil time.Time `json:"validUntil"` }
*******************************************************************
ENTITY TOKEN Entity Tokens are used to create new entities. The administrator creates an entity token and sends it to the new user. The new user uses the entity token to create an new entity. After the entity was created, the entity token is deleted.
*******************************************************************
func NewEntityToken ¶
func NewEntityToken() EntityToken
NewEntityToken creates a new entity token (token itself and validity, comming from configuration)
func (EntityToken) Delete ¶
func (et EntityToken) Delete() error
Delete the entity token from database
type NewEntityStruct ¶ added in v0.0.10
type NewEntityStruct struct { Nick string `json:"nick"` Password string `json:"password"` Secret string `json:"secret"` PasswordHash string `json:"passwordHash"` SecretHash string `json:"secretHash"` Active bool `json:"active"` WrongPasswordCounter int `json:"WrongPasswordCounter"` LastSignInAttempt time.Time `json:"lastSignInAttempt"` LastSignIn time.Time `json:"lastSignIn"` CreateTimeStamp time.Time `json:"createTimeStamp"` UpdateTimeStamp time.Time `json:"updateTimeStamp"` }
NewEntity contains all fields of Entity but also the password and the secret (not only the hash)
func NewEntity ¶
func NewEntity(entityToken, pin string) (newEntity NewEntityStruct, err error)
NewEntity creates a new entity using an entityToken and PIN
func (*NewEntityStruct) ToEntity ¶ added in v0.0.10
func (ne *NewEntityStruct) ToEntity() Entity
ToEntity converts a NewEntityStruct to Entity
type PublicEntity ¶ added in v0.0.17
type PublicEntity struct { Nick string `json:"nick"` Active bool `json:"active"` WrongPasswordCounter int `json:"WrongPasswordCounter"` LastSignInAttempt time.Time `json:"lastSignInAttempt"` LastSignIn time.Time `json:"lastSignIn"` CreateTimeStamp time.Time `json:"createTimeStamp"` UpdateTimeStamp time.Time `json:"updateTimeStamp"` }
PublicEntity describes a user or a device (without hashes)
Directories ¶
Path | Synopsis |
---|---|
The programm is a simple REST server and handles two request: 1.
|
The programm is a simple REST server and handles two request: 1. |