Documentation ¶
Index ¶
- Constants
- func AddGHR(address string, port int)
- func ClearGHR()
- func CurrentTS() (ts int64)
- func EndSession(server Server, authResponse *AuthResponse) (err error)
- func ExpiredValue(givenTimeStr string, ttl int64) (valid bool)
- func IsValidHandle(handleid string) (err error)
- func IsValidPrefix(prefix string) (err error)
- func RandomInt(min, max int) int
- func ReadPrivateRSAKey(rsaPrivBytes []byte, password string) (privateKey *rsa.PrivateKey, err error)
- func ReadYaml(inputFile string, inputStruct interface{}) (fileErr error)
- func SetCustomIRPSvc(prefix, address string, port int, desc string)
- func TSNow() (timestamp int64)
- func TimeUTC() (timeStr string)
- func WriteYaml(outputFile string, outputStruct interface{})
- type Admin
- type AdminPerm
- type Attribute
- type AuthResponse
- type Config
- type Digest
- type IRP
- func Create(server Server, authResponse *AuthResponse, handleid string, irpValues Values, ...) (irpResponse IRP)
- func Delete(server Server, authResponse *AuthResponse, handleid string) (irpResponse IRP)
- func Remove(server Server, authResponse *AuthResponse, handleid string, indexes []int) (irpResponse IRP)
- func Resolve(server Server, authResponse *AuthResponse, handleid string, param Parameter) (irpResponse IRP)
- func Update(server Server, authResponse *AuthResponse, handleid string, irpValues Values, ...) (irpResponse IRP)
- type Interface
- type JWK
- type Parameter
- type Server
- type SiteInfo
- type VList
- type VListValue
- type VListValues
- type Value
- type ValuePerm
- type Values
- func (irpValues *Values) Add(index int, irpType string, irpFormat string, irpValue interface{}, ttl int64, ...)
- func (irpValues *Values) AddAdmin(index int, adminIndex int, adminID string, ttl int64, isPrivate bool) (err error)
- func (irpValues *Values) AddBase64(index int, irpType string, input []byte, ttl int64, isPrivate bool)
- func (irpValues *Values) AddKey(index int, irpType string, j *JWK, ttl int64, isPrivate bool)
- func (irpValues *Values) AddSite(index int, irpType string, si *SiteInfo, ttl int64, isPrivate bool)
- func (irpValues *Values) AddString(index int, irpType string, str string, ttl int64, isPrivate bool)
- func (irpValues *Values) AddVList(index int, irpValue *VListValues, ttl int64, isPrivate bool)
- func (irpValues *Values) AddValue(value *Value)
Constants ¶
const ( // AdminRead - Permission index for admin read AdminRead = iota // AdminWrite - Permission index for admin write AdminWrite // PublicRead - Permission index for public read PublicRead // PublicWrite - Permission index for public read, this library does not support setting public write PublicWrite )
const DefaultTTL = 86400
DefaultTTL - Default TTL of a IRP type/value. Used by LHS to determine cache lifetime.
const (
EncodingRSA = "RSA_PUB_KEY"
)
const FormatAdmin = "admin"
FormatAdmin - IRP format for storing admin entry
const FormatBase64 = "base64"
FormatBase64 - IRP format for storing base64 entry
const FormatKey = "key"
FormatKey - IRP format for storing public keys
const FormatSite = "site"
FormatSite - IRP format for storing site information
const FormatString = "string"
FormatString - IRP format for storing string entry
const FormatVList = "vlist"
FormatVList - IRP format for storing vlist entry
const ResponseCodeAccessDenied = 401
ResponseCodeAccessDenied - Authentication required
const ResponseCodeAuthNeeded = 402
ResponseCodeAuthNeeded - No access to data
const ResponseCodeAuthenFailed = 403
ResponseCodeAuthenFailed - Failed to authenticate
const ResponseCodeError = 2
ResponseCodeError - IRP responseCode for general error
const ResponseCodeIRPAlreadyExist = 101
ResponseCodeIRPAlreadyExist - IRP already exists
const ResponseCodeInvalidIRP = 102
ResponseCodeInvalidIRP - Encoding (or syntax) error
const ResponseCodeNotAuthorized = 400
ResponseCodeNotAuthorized - Not authorized/permitted
const ResponseCodeNotFound = 100
ResponseCodeNotFound - IRP responseCode for IRP ID not found
const ResponseCodeServerNotResp = 301
ResponseCodeServerNotResp - Server not responsible
const ResponseCodeSuccess = 1
ResponseCodeSuccess - IRP responseCode for success
const ResponseCodeUnableToAuthen = 406
ResponseCodeUnableToAuthen - Unable to authenticate
const ResponseCodeValueNotFound = 200
ResponseCodeValueNotFound - Value not found
const ServerAdmin = int8(2)
ServerAdmin - seek admin server
const ServerQuery = int8(1)
ServerQuery - seek query server
const TypeHSAdmin = "HS_ADMIN"
TypeHSAdmin - IRP type/value pair for storing admins
const TypeHSPubKey = "HS_PUBKEY"
TypeHSPubKey - IRP type/value pair for storing public keys
const TypeHSSignature = "HS_SIGNATURE"
TypeHSSignature - IRP type/value pair for digital signature of this IRP Record
const TypeHSSite = "HS_SITE"
TypeHSSite - IRP type/value pair for storing site information
const TypeVList = "HS_VLIST"
TypeVList - IRP type/value pair for virtual lists, pointing to other IDs and indexes
Variables ¶
This section is empty.
Functions ¶
func EndSession ¶
func EndSession(server Server, authResponse *AuthResponse) (err error)
EndSession - deletes a given session ID. If no logout is performed, a session ID is valid for 30 minutes of inactivity.
func ExpiredValue ¶
ExpiredValue - checks if a given time and the ttl is within current time
func IsValidHandle ¶ added in v1.1.3
IsValidHandle - checks if a given handleid is valid
func IsValidPrefix ¶ added in v1.1.3
IsValidPrefix - checks if a given prefix is valid
func ReadPrivateRSAKey ¶
func ReadPrivateRSAKey(rsaPrivBytes []byte, password string) (privateKey *rsa.PrivateKey, err error)
ReadPrivateRSAKey - reads a given private key PEM bytes
func ReadYaml ¶
ReadYaml - reads a given input YAML file and returns the struct mapped from the file
func SetCustomIRPSvc ¶
SetCustomIRPSvc - sets a custom IRP service for connection
func TSNow ¶
func TSNow() (timestamp int64)
TSNow - return the current timestamp in UTC for consistency
Types ¶
type Admin ¶
type Admin struct { Handle string `json:"handle"` Index int `json:"index"` Permissions string `json:"permissions"` // contains filtered or unexported fields }
Admin - admin IRP value format
func (*Admin) ClearPermission ¶
func (admin *Admin) ClearPermission()
ClearPermission - clears all permissions to start afresh
func (*Admin) HasPermission ¶
HasPermission - checks if admin has requested permission
func (*Admin) SetDefaultPermission ¶
func (admin *Admin) SetDefaultPermission()
SetDefaultPermission - default permission for a IRP Admin
func (*Admin) SetPermission ¶
SetPermission - sets permission for a IRP Admin
type AdminPerm ¶
type AdminPerm int
const ( // PermReadValues - Permission index for reading private values PermReadValues AdminPerm = iota + 1 // PermAdminAdd - Permission index for adding new admins to THIS IRP Record PermAdminAdd // PermAdminRemove - Permission index for removing existing admins from THIS IRP Record PermAdminRemove // PermAdminModify - Permission index for modifying existing admins from THIS IRP Record PermAdminModify // PermValueAdd - Permission index for adding new values to THIS IRP Record PermValueAdd // PermValueRemove - Permission index for removing existing values from THIS IRP Record PermValueRemove // PermValueModify - Permission index for modifying existing values from THIS IRP Record PermValueModify // PermDeleteIRP - Permission index for deleting THIS IRP Record PermDeleteIRP AdminPerm = iota + 3 )
type Attribute ¶
type Attribute struct { Name string `yaml:"name" json:"name"` Value string `yaml:"value" json:"value"` }
Attribute - attributes for site information
func NewAttribute ¶
NewAttribute - creates a new instance of attribute
type AuthResponse ¶
type AuthResponse struct { Error string `json:"error,omitempty"` Authenticated bool `json:"authenticated"` ServerAuthenticated bool `json:"-"` Nonce string `json:"nonce"` SessionID string `json:"sessionId"` ServerAlg string `json:"serverAlg,omitempty"` ServerSignature string `json:"serverSignature,omitempty"` LastAccess int64 `json:"-"` Client *http.Client `json:"-"` }
AuthResponse - response from LHS for authentication
func Authenticate ¶
func Authenticate(server Server, authIndex int, authIRP string, j *JWK) (authResponse *AuthResponse, err error)
Authenticate - performs IRP Authentication and returns a valid response
type Config ¶
type Config struct { Directory string `yaml:"-"` ServerInfoDirectory string `yaml:"-"` //LibraryDirectory string `yaml:"-"` GHR []*Server `yaml:"-"` }
Config - configuration information to this IRP Bridge
type IRP ¶
type IRP struct { ResponseCode int `json:"responseCode,omitempty"` Handle string `json:"handle,omitempty"` Values Values `json:"values,omitempty"` Message string `json:"message,omitempty"` }
IRP - IRP Record structure for IRP HTTP REST
func Create ¶
func Create(server Server, authResponse *AuthResponse, handleid string, irpValues Values, overwrite bool) (irpResponse IRP)
Create - creates a IRP ID with given values
func Delete ¶
func Delete(server Server, authResponse *AuthResponse, handleid string) (irpResponse IRP)
Delete - deletes a given IRP Record
func Remove ¶
func Remove(server Server, authResponse *AuthResponse, handleid string, indexes []int) (irpResponse IRP)
Remove - removes given indexes from a IRP Record
func Resolve ¶
func Resolve(server Server, authResponse *AuthResponse, handleid string, param Parameter) (irpResponse IRP)
Resolve - resolves a given IRP ID using authentication
func Update ¶
func Update(server Server, authResponse *AuthResponse, handleid string, irpValues Values, overwrite bool) (irpResponse IRP)
Update - updates a IRP ID with given values
func (*IRP) GetByIndex ¶
GetByIndex - returns a IRP Value by index
type Interface ¶
type Interface struct { Admin bool `yaml:"admin" json:"admin"` Query bool `yaml:"query" json:"query"` Port int `yaml:"port" json:"port"` Protocol string `yaml:"protocol" json:"protocol"` }
Interface - interface information for the site server
type JWK ¶ added in v1.1.0
type JWK signedtoken.JWK // create a new type based on `signedtoken.JWK` for reference in this library
type Parameter ¶
Parameter - optional parameters to send to the Connect function to not clutter up the input variables
type Server ¶
type Server struct { Address string `json:"address"` Interfaces []Interface `yaml:"interfaces" json:"interfaces"` ServerID int `yaml:"serverId,omitempty" json:"serverId,omitempty"` PublicKey struct { Format string `yaml:"format,omitempty" json:"format,omitempty"` Value JWK `yaml:"value,omitempty" json:"value,omitempty"` } `yaml:"publicKey,omitempty" json:"publicKey,omitempty"` // contains filtered or unexported fields }
Server - server information stored in the site information
func GetPrefixSite ¶
GetPrefixSite - get where this prefix lives from the MPA
func (*Server) AddInterface ¶
AddInterface - adds a new interface for this server
type SiteInfo ¶
type SiteInfo struct { Attributes []Attribute `yaml:"attributes" json:"attributes,omitempty"` MultiPrimary bool `yaml:"multiPrimary,omitempty" json:"multiPrimary"` PrimarySite bool `yaml:"primarySite,omitempty" json:"primarySite"` ProtocolVersion string `yaml:"protocolVersion,omitempty" json:"protocolVersion"` SerialNumber int `yaml:"serialNumber,omitempty" json:"serialNumber"` Servers []Server `yaml:"servers,omitempty" json:"servers,omitempty"` Version int `yaml:"version,omitempty" json:"version,omitempty"` TTL int64 `yaml:"ttl" json:"ttl"` // we keep TTL here to be used by the library or applications LastUpdate string `yaml:"lastupdate,omitempty" json:"-"` // used by library to know if the cached site information is still valid }
SiteInfo - Handle data for sites
func NewSiteInfo ¶
func NewSiteInfo() (siteInfo *SiteInfo)
NewSiteInfo - creates a new instance of site information
func (*SiteInfo) GetServers ¶
GetServers - returns list of servers configured for this prefix
type VList ¶
type VList struct { Index int `json:"index"` Values []struct { IRP string `json:"handle"` Index int `json:"index"` } `json:"values"` TTL int64 `json:"ttl"` // optional. default value will be used if this is not given AdminOnly bool `json:"admin_only"` // optional. sane public permissions will be set if not given }
VList - format for IRP Request storing HS_VLIST information
type VListValue ¶
VListValue - stores VList values
type VListValues ¶
type VListValues []VListValue
VListValues - array of VList values for storage in an Handle Record
func NewVList ¶
func NewVList() (vListValues *VListValues)
NewVList - creates a new instance of `VListValues`
type Value ¶
type Value struct { Index int `json:"index"` Type string `json:"type"` Data struct { Format string `json:"format"` Value interface{} `json:"value"` } `json:"data"` Permissions string `json:"permissions,omitempty"` TTL int64 `json:"ttl"` Timestamp string `json:"timestamp,omitempty"` // contains filtered or unexported fields }
Value - IRP value structure
func CreateDigest ¶
func CreateDigest(handleid string, index int, expires int64, irpValues Values, authIndex int, authIRP string, j *JWK) (dgValue *Value, err error)
CreateDigest - creates digests of given IRP values
func (*Value) HasPermission ¶ added in v1.1.7
HasPermission - checks if value has requested permission
func (*Value) SetPermPrivateRW ¶
func (value *Value) SetPermPrivateRW()
SetPermPrivateRW - sets permission for a IRP Value for admin only
func (*Value) SetPermPublicRead ¶
SetPermPublicRead - sets permission for a IRP Value for public read
type Values ¶
type Values []Value
Values - array of values for a IRP Request
func (*Values) Add ¶
func (irpValues *Values) Add(index int, irpType string, irpFormat string, irpValue interface{}, ttl int64, isPrivate bool)
Add - generic add value to an IRP Request
func (*Values) AddAdmin ¶
func (irpValues *Values) AddAdmin(index int, adminIndex int, adminID string, ttl int64, isPrivate bool) (err error)
AddAdmin - adds an admin value to an IRP Request Values
func (*Values) AddBase64 ¶
func (irpValues *Values) AddBase64(index int, irpType string, input []byte, ttl int64, isPrivate bool)
AddBase64 - adds a base64 (standard encoding) value to an IRP Request Values
func (*Values) AddSite ¶
func (irpValues *Values) AddSite(index int, irpType string, si *SiteInfo, ttl int64, isPrivate bool)
AddSite - adds a site information value to an IRP Request Values
func (*Values) AddString ¶
func (irpValues *Values) AddString(index int, irpType string, str string, ttl int64, isPrivate bool)
AddString - adds a string value to an IRP Request Values