Documentation ¶
Index ¶
- func AddEndpoint(ep *Endpoint)
- func AddEndpoints(eps ...*Endpoint)
- func AuditedSend(ctx echo.Context, res *Result) (err error)
- func AuditedSendSecret(ctx echo.Context, res *Result) (err error)
- func AuditedSendX(ctx echo.Context, data interface{}, res *Result) (err error)
- func DefMS(oprn string) (int, string)
- func DefaultSM(opern, name string) (int, string)
- func DoLogin(userID string, password string) (*vsec.User, error)
- func GetDateRange(ctx echo.Context) (dr vcmn.DateRange, err error)
- func GetJWTKey() []byte
- func GetOffsetLimit(ctx echo.Context) (offset, limit int, has bool)
- func GetQueryParam(ctx echo.Context, name string, def string) (val string)
- func GetRootPath() string
- func GetString(ctx echo.Context, key string) (value string)
- func GetToken(ctx echo.Context) (token *jwt.Token, err error)
- func InitWithOptions(opts Options)
- func IsAdmin(ctx echo.Context) (yes bool)
- func IsNormalUser(ctx echo.Context) (yes bool)
- func IsSuperUser(ctx echo.Context) (yes bool)
- func LoadJSONFromArgs(ctx echo.Context, param string, out interface{}) (err error)
- func ModifiedHTTPErrorHandler(err error, c echo.Context)
- func NoOpAuthenticator(params map[string]interface{}) (*vsec.User, error)
- func NoOpAuthorizer(userID string) (vsec.AuthLevel, error)
- func SendAndAuditOnErr(ctx echo.Context, res *Result) (err error)
- func SendEmail(to, subject, meesage string) (err error)
- func Serve(port int) (err error)
- type Authenticator
- type Authorizer
- type BinderFunc
- type Client
- func (client *Client) CreateURL(access vsec.AuthLevel, args ...string) (str string)
- func (client *Client) Delete(access vsec.AuthLevel, urlArgs ...string) (rr *ResultReader)
- func (client *Client) Get(access vsec.AuthLevel, urlArgs ...string) (rr *ResultReader)
- func (client *Client) Login(userID, password string) (err error)
- func (client *Client) Post(content interface{}, access vsec.AuthLevel, urlArgs ...string) (rr *ResultReader)
- func (client *Client) Put(content interface{}, access vsec.AuthLevel, urlArgs ...string) (rr *ResultReader)
- type EmailConfig
- type Endpoint
- type M
- type Options
- type Result
- type ResultReader
- type Session
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddEndpoints ¶
func AddEndpoints(eps ...*Endpoint)
AddEndpoints - registers multiple REST categories
func AuditedSend ¶
AuditedSend - sends result as JSON while logging it as event. The event data is same as the data present in the result
func AuditedSendSecret ¶
AuditedSendSecret - Sends result to client and logs everything other than the secret data field
func AuditedSendX ¶
AuditedSendX - sends result as JSON while logging it as event. This method logs event data which is seperate from result data
func GetDateRange ¶
GetDateRange - Retrieve date range from context, assuming that there exist 2 REST params with name from and to respectively
func GetOffsetLimit ¶
GetOffsetLimit - retrieves offset and limit as integers provided in URL as query parameters. These parameters should have name - offset and limit respectively
func GetQueryParam ¶
GetQueryParam - get query param if present otherwise return the default
func GetRootPath ¶
func GetRootPath() string
GetRootPath - get base URL of the configured application's REST Endpoints
func InitWithOptions ¶
func InitWithOptions(opts Options)
InitWithOptions - initializes all the registered endpoints
func IsNormalUser ¶
IsNormalUser - returns true if user is a normal user
func IsSuperUser ¶
IsSuperUser - returns true if user is a super user
func LoadJSONFromArgs ¶
LoadJSONFromArgs - decodes argument identified by 'param' to JSON and unmarshals it into the given 'out' structure
func ModifiedHTTPErrorHandler ¶
ModifiedHTTPErrorHandler is the default HTTP error handler. It sends a JSON response with status code. [Modefied from echo.DefaultHTTPErrorHandler]
func NoOpAuthenticator ¶
NoOpAuthenticator - authenticator that does not do anything
func NoOpAuthorizer ¶
NoOpAuthorizer - authorizer that does not do anything
func SendAndAuditOnErr ¶
SendAndAuditOnErr - sends the result to client and puts an audit record in audit log if the result is error OR sending failed
Types ¶
type Authenticator ¶
Authenticator - a function that is used to authenticate an user. The function takes map of parameters contents of which will differ based on actual function used
type Authorizer ¶
Authorizer - a function that will be used authorize an user
type BinderFunc ¶
BinderFunc - a function that binds data struct to response body
type Client ¶
type Client struct { http.Client Address string VersionStr string BaseURL string Token string User *vsec.User }
Client - client for orek service
func (*Client) CreateURL ¶
CreateURL - constructs URL from base URL, access level and the given path components
func (*Client) Delete ¶
func (client *Client) Delete( access vsec.AuthLevel, urlArgs ...string) (rr *ResultReader)
Delete - performs a delete request
func (*Client) Get ¶
func (client *Client) Get( access vsec.AuthLevel, urlArgs ...string) (rr *ResultReader)
Get - performs a get request
func (*Client) Login ¶
Login - login to a vaali based service with userID and password. If successful client will have the session information and can perform REST calls that needs authentication
type EmailConfig ¶
type EmailConfig struct { AppEMail string `json:"appEMail"` AppEMailPassword string `json:"appEMailPassword"` SMTPHost string `json:"smtpHost"` SMTPPort int `json:"smtpPort"` }
EmailConfig - configuration for sending email
type Endpoint ¶
type Endpoint struct { OID bson.ObjectId `json:"_id"` Method string `json:"method"` URL string `json:"url"` Access vsec.AuthLevel `json:"access"` Category string `json:"cateogry"` Route *echo.Route `json:"route"` Comment string `json:"Comment"` Func echo.HandlerFunc }
Endpoint - represents a REST endpoint with associated metadata
func GetEndpoints ¶
func GetEndpoints() (endpoints []*Endpoint)
GetEndpoints - Export app security related APIs
type Options ¶
type Options struct { RootName string APIVersion string Authenticator Authenticator Authorizer Authorizer }
Options - options for initializing web APIs
type Result ¶
type Result struct { Status int `json:"status" bson:"status"` Op string `json:"op" bson:"op"` Msg string `json:"msg" bson:"msg"` OK bool `json:"ok" bson:"ok"` Err string `json:"error" bson:"error"` Data interface{} `json:"data" bson:"data"` }
Result - result of an API call
type ResultReader ¶
ResultReader - proto result, use it to read the Result with proper data struct
func NewResultReader ¶
func NewResultReader(r *http.Response) (reader *ResultReader)
NewResultReader - creates a new result-reader from response body
func (*ResultReader) Finish ¶
func (rr *ResultReader) Finish() (err error)
Finish - decodes the server response and returns error if it failed. Use this method if data is not expected from server call
func (*ResultReader) Read ¶
func (rr *ResultReader) Read(data interface{}) (err error)
Read - read result data from reader. The provided data object will be populatd with result's data field