pkg

package
v0.0.0-...-e94039c Latest Latest
Warning

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

Go to latest
Published: May 26, 2019 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoFormUrlencoded     = errors.New("Request's content-type is not application/x-www-form-urlencoded ")
	NoFormPost           = errors.New("Request is not POST")
	ErrorCSRFExpired     = errors.New("CSRF Expired.")
	ErrorCSRFInvalidUser = errors.New("CSRF Invalid User.")
	ErrorCSRFInvalidURL  = errors.New("CSRF Invalid URL.")
)
View Source
var (
	ErrorInvalidToken   = errors.New("Invalid Token.")
	ErrorSessionExpired = errors.New("Session Expired.")
)
View Source
var (
	ErrorConfigNotExists = errors.New("Config does not existed.")
)

Functions

func AddCookie2Param

func AddCookie2Param(param map[string]interface{}, key string, val string, secure bool) map[string]interface{}

func GenerateCSRF

func GenerateCSRF(user tinylib.UserInterface, url string, seconds int) (string, error)

func GenerateParam

func GenerateParam(request events.APIGatewayProxyRequest) (map[string]interface{}, tinylib.UserInterface)

func GenerateSession

func GenerateSession(user tinylib.UserInterface) (string, error)

func GetCookieByRequest

func GetCookieByRequest(request events.APIGatewayProxyRequest, cookie_name string) (string, error)

func GetUserBySession

func GetUserBySession(tokenStr string) (tinylib.UserInterface, error)

func InitCmsConfig

func InitCmsConfig() error

func LoginByTwitter

func LoginByTwitter(url_prefix string, request events.APIGatewayProxyRequest, param map[string]interface{}, user tinylib.UserInterface) (events.APIGatewayProxyResponse, error)

func LoginByTwitterCallback

func LoginByTwitterCallback(request events.APIGatewayProxyRequest, param map[string]interface{}, user tinylib.UserInterface) (events.APIGatewayProxyResponse, error)

func ParseFormUrlencoded

func ParseFormUrlencoded(request events.APIGatewayProxyRequest) (map[string]string, error)

func Redirect

func Redirect(url string, param map[string]interface{}) events.APIGatewayProxyResponse

Redirect page by status code 302

func ShowAccountPage

func ShowAccountPage(url_prefix string, request events.APIGatewayProxyRequest, param map[string]interface{}, user tinylib.UserInterface) (events.APIGatewayProxyResponse, error)

func ShowConfig

func ShowConfig(request events.APIGatewayProxyRequest, param map[string]interface{}, user tinylib.UserInterface) (events.APIGatewayProxyResponse, error)

func ShowLocalUserCreatePage

func ShowLocalUserCreatePage(url_prefix string, request events.APIGatewayProxyRequest, param map[string]interface{}, user tinylib.UserInterface) (events.APIGatewayProxyResponse, error)

func ShowTemplate

func ShowTemplate(request events.APIGatewayProxyRequest, templateFile string, param map[string]interface{}) (events.APIGatewayProxyResponse, error)

Show HTML page generated by pongo2 template with status code 200

func ShowTemplateWithStatusCode

func ShowTemplateWithStatusCode(request events.APIGatewayProxyRequest, templateFile string, param map[string]interface{}, statuscode int) (events.APIGatewayProxyResponse, error)

Show HTML page generated by pongo2 template with any status code

func ShowTermOfUsePage

func ShowTermOfUsePage(url_prefix string, request events.APIGatewayProxyRequest, param map[string]interface{}, user tinylib.UserInterface) (events.APIGatewayProxyResponse, error)

func ValidateCSRF

func ValidateCSRF(csrf string, user tinylib.UserInterface, url string) (bool, error)

Types

type CmsConfigInterface

type CmsConfigInterface interface {
	Save() error
	GetStatus() string
	GetStatusCode() int
	GetURL_PREFIX() string
	GetTinyConfig() tinylib.ConfigInterface
	GetTermOfUse() TermOfUseInterface
	GetGoogleOauthClient() string
	GetGoogleOauthSecret() string
	GetTwitterConsumerKey() string
	GetTwitterConsumerSecret() string
	UpdateStatus(string)
	UpdateStatusCode(int)
	// contains filtered or unexported methods
}

func GetCmsConfig

func GetCmsConfig() (CmsConfigInterface, error)

type Oauth2Config

type Oauth2Config struct {
	Config oauth2.Config
}

func MakeOauth2Conf4google

func MakeOauth2Conf4google(clientid string, clientsecret string, callback_url string) Oauth2Config

func (*Oauth2Config) Login4google

func (self *Oauth2Config) Login4google(request events.APIGatewayProxyRequest, jwt_secret string) (events.APIGatewayProxyResponse, error)

func (*Oauth2Config) LoginCallback4google

func (self *Oauth2Config) LoginCallback4google(request events.APIGatewayProxyRequest, jwt_secret string) (*v2.Tokeninfo, error)

type Oauth2Token

type Oauth2Token struct {
	Token       string
	ExpiredDate time.Time
	jwt.StandardClaims
}

type TermOfUseInterface

type TermOfUseInterface interface {
	Save() error
	Publish() error
	GetHTML() string
	SetHTML(string)
	GetPublishDate() string
}

func GetDraftTermOfUse

func GetDraftTermOfUse() (TermOfUseInterface, error)

func GetLatestTermOfUse

func GetLatestTermOfUse() (TermOfUseInterface, error)

Jump to

Keyboard shortcuts

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