Documentation ¶
Index ¶
- Variables
- func GeneratePem(privateKey *rsa.PrivateKey) (string, error)
- func GeneratePub(privateKey *rsa.PrivateKey) (string, error)
- func RegisterModel(snaphyModel ...interface{})
- type Application
- func (app *Application) Activate() (num int64, err error)
- func (app *Application) Create() error
- func (app *Application) Deactivate() (num int64, err error)
- func (app *Application) Delete() (num int64, err error)
- func (app *Application) FetchAppSettings() (num int64, err error)
- func (app *Application) FetchAppTokens() (num int64, err error)
- func (app *Application) GetApp() (err error)
- type ApplicationSettings
- type GraphApp
- func (app *GraphApp) AddUniqueConstraint() (err error)
- func (app *GraphApp) Create() (err error)
- func (app *GraphApp) CreateIfNotExist() (err error)
- func (app *GraphApp) Delete() (err error)
- func (app *GraphApp) Exist() (exist bool, err error)
- func (app *GraphApp) Get() (exist bool, err error)
- func (app *GraphApp) Read() (err error)
- func (app *GraphApp) ReadAll(appList []*interface{}) (err error)
- func (app *GraphApp) Update(err error)
- type Group
- func (group *Group) AddUniqueConstraint() (err error)
- func (group *Group) Create() (err error)
- func (group *Group) CreateIfNotExist() (err error)
- func (group *Group) Delete() (err error)
- func (group *Group) Exist() (exist bool, err error)
- func (group *Group) Read() (err error)
- func (group *Group) ReadAll(groupListInterface []*interface{}) (err error)
- func (group *Group) Update() (err error)
- type Realm
- func (realm *Realm) AddUniqueConstraint() (err error)
- func (realm *Realm) Create() (err error)
- func (realm *Realm) CreateIfNotExist() (err error)
- func (realm *Realm) CreateTag(tag *TokenTag) (err error)
- func (realm *Realm) Delete() (err error)
- func (realm *Realm) Exist() (exist bool, err error)
- func (realm *Realm) Read() (err error)
- func (realm *Realm) ReadAll(realmListInterface []*interface{}) (err error)
- func (realm *Realm) Update() (err error)
- type RelIdentity
- type Token
- func (token *Token) AddTag(tokenTag *TokenTag) (err error)
- func (token *Token) AddUniqueConstraint() (err error)
- func (token *Token) CheckIfTokenValid(tokenHelper *TokenHelper) (ok bool, err error)
- func (token *Token) CheckTokenExpiry() (ok bool, err error)
- func (token *Token) Create() (err error)
- func (token *Token) CreateIfNotExist() (err error)
- func (token *Token) Delete(err error)
- func (token *Token) Exist() (exist bool, err error)
- func (token *Token) GenerateLoginToken(previousToken *Token) (err error)
- func (token *Token) GenerateSignature(tokenHelper *TokenHelper, realm *Realm, group *Group, tag *TokenTag, ...) (tokenString string, err error)
- func (token *Token) GetTokenHelper(appId string) (tokenHelper *TokenHelper, err error)
- func (token *Token) LookUpKey(appId string, tokenHelper *TokenHelper) (publicKey []byte, err error)
- func (token *Token) Read() (err error)
- func (token *Token) ReadAll(tokenTagListInterface []*interface{}) (err error)
- func (token *Token) RefreshToken(previousToken *Token) (err error)
- func (token *Token) Update(err error)
- func (loginToken *Token) VerifyAndParse(tokenString string) (valid bool, err error)
- func (token *Token) VerifyHash(tokenString string) (ok bool, err error)
- type TokenHelper
- func (token *TokenHelper) CheckAppStatus() (ok bool, err error)
- func (token *TokenHelper) Create() (id int64, err error)
- func (token *TokenHelper) Delete() (num int64, err error)
- func (token *TokenHelper) DownloadPrivateKey() (err error)
- func (token *TokenHelper) DownloadPublicKey() (err error)
- func (token *TokenHelper) FetchTokenHelperApp() (num int64, err error)
- func (token *TokenHelper) GetToken() (err error)
- type TokenTag
- func (tokenTag *TokenTag) AddUniqueConstraint() (err error)
- func (tokenTag *TokenTag) Create() (err error)
- func (tokenTag *TokenTag) CreateIfNotExist() (err error)
- func (tokenTag *TokenTag) Delete() (err error)
- func (tokenTag *TokenTag) Exist() (exist bool, err error)
- func (tokenTag *TokenTag) Read() (err error)
- func (tokenTag *TokenTag) ReadAll(tokenTagListInterface []*interface{}) (err error)
- func (tokenTag *TokenTag) Update() (err error)
- type User
- func (user *User) Activate() (int64, error)
- func (user *User) Create() (id int64, err error)
- func (user *User) Deactivate() (int64, error)
- func (user *User) Delete() (num int64, err error)
- func (user *User) FetchApps() (num int64, err error)
- func (user *User) GetCustomUser(key string) (err error)
- func (user *User) GetUser() (err error)
Constants ¶
This section is empty.
Variables ¶
var (
StatusMap map[string]string
)
Functions ¶
func GeneratePem ¶
func GeneratePem(privateKey *rsa.PrivateKey) (string, error)
Generate private key in pem format..
func GeneratePub ¶
func GeneratePub(privateKey *rsa.PrivateKey) (string, error)
http://stackoverflow.com/questions/13555085/save-and-load-crypto-rsa-privatekey-to-and-from-the-disk Generate public key file pub format..
func RegisterModel ¶
func RegisterModel(snaphyModel ...interface{})
Types ¶
type Application ¶
type Application struct { Id int Name string `orm:"unique"` Status string `orm:"default(active)"` Added time.Time `orm:"auto_now_add;type(datetime)"` LastUpdated time.Time `orm:"auto_now;type(datetime)"` Owner *User `orm:"null;rel(fk)"` TokenInfo []*TokenHelper `orm:"null;reverse(many)"` Settings *ApplicationSettings `orm:"rel(one); null"` // OneToOne relation }
func (*Application) Activate ¶
func (app *Application) Activate() (num int64, err error)
Deactivate a user account...
func (*Application) Create ¶
func (app *Application) Create() error
Used for creating an application....
func (*Application) Deactivate ¶
func (app *Application) Deactivate() (num int64, err error)
Deactivate a user account...
func (*Application) Delete ¶
func (app *Application) Delete() (num int64, err error)
Only delete a user by ID
func (*Application) FetchAppSettings ¶
func (app *Application) FetchAppSettings() (num int64, err error)
func (*Application) FetchAppTokens ¶
func (app *Application) FetchAppTokens() (num int64, err error)
func (*Application) GetApp ¶
func (app *Application) GetApp() (err error)
Get the application listed whose application id is given..
type ApplicationSettings ¶
type ApplicationSettings struct { Id int ExpiryDuration int //Time in seconds after which it token will expired.. Added time.Time `orm:"auto_now_add;type(datetime)"` LastUpdated time.Time `orm:"auto_now;type(datetime)"` Application *Application `orm:"reverse(one)"` // Reverse relationship (optional) }
type GraphApp ¶
Writing node model definitons..
func (*GraphApp) AddUniqueConstraint ¶
func (*GraphApp) CreateIfNotExist ¶
Will return an error if the node already exists..
func (*GraphApp) Delete ¶
DELETE ALL DATA INCLUDING ITS NODE TO.. TODO WARNING WHEN PREPARING GRAPHQL END POINT ADD A WEEK TIME AFTER WHICH THIS DATABASE WILL GET DELETED. TODO DEACTIVATE APP WITHIN THIS TIME AND PERMANENTLY DELETE AFTER ONE WEEK TODO ALSO SEND AN EMAIL WARNING DELETING OF DATA.
func (*GraphApp) Exist ¶
Create App in graphDb first find if any global application name is present..
type Group ¶
func (*Group) AddUniqueConstraint ¶
func (*Group) CreateIfNotExist ¶
Throw error if not exist..
type Realm ¶
type Realm struct { Name string //Must be unique among the app AppId int Id string //uuid unique identifier.. }
func (*Realm) AddUniqueConstraint ¶
func (*Realm) Create ¶
Merge if exist also create relationship with app..dont create realm without relationship
func (*Realm) CreateIfNotExist ¶
Throw error if not exist..
type RelIdentity ¶
type RelIdentity struct {
// contains filtered or unexported fields
}
Writing relationship struct..
type Token ¶
type Token struct { IAT int64 //Issued at ISS int64 //User Identity EXP int64 //Expiry Time JTI string //Unique string identifies a token GRP string //Group REALM string //realm name KID string //AppId its not applicationID but AppId in TokenHelper file to track application..... STATUS string //Status showing the token is invalid or what. }
func (*Token) AddUniqueConstraint ¶
func (*Token) CheckIfTokenValid ¶
func (token *Token) CheckIfTokenValid(tokenHelper *TokenHelper) (ok bool, err error)
Complete method for checking if the token is valid or not.. Required a parsed token..
func (*Token) CheckTokenExpiry ¶
This doesn't checks if the main Application is Active or not. Check if token is expired or present in the node or status is invalid or what not ... TRUE IF TOKEN IS VALID AND FALSE IF NOT
func (*Token) Create ¶
Will simply add token data to graph database with depedencies.. token does not support merge create. It will create only if token doesnot exist and will throw an error if it exist..
func (*Token) CreateIfNotExist ¶
Throw error if not exist..
func (*Token) GenerateLoginToken ¶
func (*Token) GenerateSignature ¶
func (token *Token) GenerateSignature(tokenHelper *TokenHelper, realm *Realm, group *Group, tag *TokenTag, userIdentity string) (tokenString string, err error)
Create first time Token and Generate Signature.. Generate Signature for the token and Also add tokens to graph Database..
func (*Token) GetTokenHelper ¶
func (token *Token) GetTokenHelper(appId string) (tokenHelper *TokenHelper, err error)
func (*Token) LookUpKey ¶
func (token *Token) LookUpKey(appId string, tokenHelper *TokenHelper) (publicKey []byte, err error)
Find the public key with the provided data..
func (*Token) ReadAll ¶
Find the token from the database and populate the data.. Provide the nodeToken with jwt field or by userIdentity.
func (*Token) RefreshToken ¶
func (*Token) VerifyAndParse ¶
Parses the token value..And also validates the algorithm.. Return invalid if any error occures..
func (*Token) VerifyHash ¶
Verify the token before parsing .. the token just checks if the tokens ia a valid one. NOTE: This method just verify the encryption of algorithm and remains silent about expiry of tokens or token not present in the graph.
type TokenHelper ¶
type TokenHelper struct { Id int PublicKey string `orm:"unique;size(2050)"` //Used to decrypt PrivateKey string `orm:"unique;size(2050)"` //Used to envrypt HashType string AppSecret string `orm:"unique"` AppId string `orm:"unique"` Application *Application `orm:"rel(fk)"` Status string `orm:"default(active)"` Added time.Time `orm:"auto_now_add;type(datetime)"` LastUpdated time.Time `orm:"auto_now;type(datetime)"` }
func (*TokenHelper) CheckAppStatus ¶
func (token *TokenHelper) CheckAppStatus() (ok bool, err error)
Check if app status is expired or not
func (*TokenHelper) Create ¶
func (token *TokenHelper) Create() (id int64, err error)
Used for creating a token.. Only Application
func (*TokenHelper) Delete ¶
func (token *TokenHelper) Delete() (num int64, err error)
Only delete a token by ID
func (*TokenHelper) DownloadPrivateKey ¶
func (token *TokenHelper) DownloadPrivateKey() (err error)
func (*TokenHelper) DownloadPublicKey ¶
func (token *TokenHelper) DownloadPublicKey() (err error)
func (*TokenHelper) FetchTokenHelperApp ¶
func (token *TokenHelper) FetchTokenHelperApp() (num int64, err error)
func (*TokenHelper) GetToken ¶
func (token *TokenHelper) GetToken() (err error)
Method for generating token.. Get token
type TokenTag ¶
type TokenTag struct { Id string //UUID unique identifier.. AppId int RealmName string Name string //unique among a particular realm and application. }
func (*TokenTag) AddUniqueConstraint ¶
func (*TokenTag) CreateIfNotExist ¶
type User ¶
type User struct { Id int FirstName string LastName string Email string Status string `orm:"default(active)"` Added time.Time `orm:"auto_now_add;type(datetime)"` LastUpdated time.Time `orm:"auto_now;type(datetime)"` Apps []*Application `orm:"null;reverse(many)"` }
func (*User) Deactivate ¶
Deactivate a user account...