persistence

package
v0.0.0-...-c4f9bb7 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2019 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Prefix Env variable used by micro service should all be prefixed
	Prefix = "CIDM"
	//UserInfoAPI Google API
	UserInfoAPI = "https://www.googleapis.com/oauth2/v2/userinfo?access_token="
)
View Source
const (
	//OauthType constant definition
	OauthType = "OAUTH2"
	//OauthGoogle constant definition for Oauth 2 google service
	OauthGoogle = "OAUTH2-GOOGLE"
)

Variables

This section is empty.

Functions

func AddResource

func AddResource(resource models.Resource) (models.Resource, error)

AddResource to the global data base

func AddResourceToUser

func AddResourceToUser(user models.User, resource models.Resource, operation string) (models.Permission, error)

AddResourceToUser add resource to a particular User.

func CreateUser

func CreateUser(user models.User) error

CreateUser in persisted storage

func DeletePermission

func DeletePermission(permission models.Permission) (models.Permission, error)

DeletePermission an existing permission for a particular user.

func DeleteResource

func DeleteResource(resource models.Resource) (models.Resource, error)

DeleteResource in the data base.

func GetDefaultLogin

func GetDefaultLogin() (models.Login, error)

GetDefaultLogin Returns the system default login for an specific running instance

func GetEnvVariable

func GetEnvVariable(key string) string

GetEnvVariable get enviroment variable from OS/ host system only variables prefixed with persitence . Prefix will be returned

func GetGoogleUserAPI

func GetGoogleUserAPI() string

GetGoogleUserAPI get API Uri end point

func GetLoginByID

func GetLoginByID(id int64) (models.Login, error)

GetLoginByID get login details by Id

func GetOauthStateString

func GetOauthStateString() string

GetOauthStateString get state string for oauth connection

func GetPermission

func GetPermission(user models.User, resource models.Resource, operation string) (models.Permission, error)

GetPermission critical function

func GetPermissionsByUser

func GetPermissionsByUser(user models.User) ([]models.Permission, error)

GetPermissionsByUser get permission given a particular user.

func GetPersistedConfig

func GetPersistedConfig(name string) (models.Configuration, error)

GetPersistedConfig Returns a persisted configuration in the data base from configurations

func GetPortBase

func GetPortBase() string

GetPortBase Returns the current port base for the particular server.

func GetResourceByID

func GetResourceByID(id string) (models.Resource, error)

GetResourceByID get resource by its Id that could be represented as a canonical uri.

func GetServerAddress

func GetServerAddress() string

GetServerAddress get global server Base.

func GetServerBase

func GetServerBase() string

GetServerBase gives the current server ip address.

func GetToken

func GetToken(token models.UserToken) (models.UserToken, error)

GetToken from table

func GoogleUserByToken

func GoogleUserByToken(token oauth2.Token) (models.User, error)

GoogleUserByToken this procedure will take a valid token Id and return a user from Google userinfo API

func Insert

func Insert(loginID models.Login) (models.Login, error)

Insert a new login as Login model into the persisted storage

func IsAuthorized

func IsAuthorized(user models.User, resource models.Resource, operation string) bool

IsAuthorized backbone function to check authorization.

func OauthAuthenticationTokenByType

func OauthAuthenticationTokenByType(auth string, state string, code string) (*oauth2.Token, error)

OauthAuthenticationTokenByType get a token based on the type of authentication defined , this will connect with external parties.

func OauthAuthenticationURLByType

func OauthAuthenticationURLByType(auth string) string

OauthAuthenticationURLByType returns the login authentication for an specific OAuth 2 service

func Update

func Update(login models.Login) (models.Login, error)

Update an existing login

func UpdatePermission

func UpdatePermission(permission models.Permission) (models.Permission, error)

UpdatePermission update an existin permission for a particular user.

func UpdatePersistedConfig

func UpdatePersistedConfig(config models.Configuration) error

UpdatePersistedConfig updates a persisted configuration value

func UpdateResource

func UpdateResource(resource models.Resource) (models.Resource, error)

UpdateResource in the DB

func UpdateToken

func UpdateToken(token models.UserToken) error

UpdateToken existing token associated with a particular user

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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