Example #1
0
func (c Auth) CbAction() {

	session, err := idclient.Instance(c.Params.Get("access_token"))
	if err != nil {
		c.Redirect(idclient.AuthServiceUrl(
			config.Config.InstanceID,
			fmt.Sprintf("//%s%s/auth/cb", c.Request.Host, config.HttpSrvBasePath("")), c.Params.Get("state")))
		return
	}

	http.SetCookie(c.Response.Out, &http.Cookie{
		Name:     "access_userid",
		Value:    session.UserID,
		Path:     "/",
		HttpOnly: false,
		Expires:  time.Now().Add(time.Second * time.Duration(c.Params.Int64("expires_in"))),
	})

	http.SetCookie(c.Response.Out, &http.Cookie{
		Name:     idclient.AccessTokenKey,
		Value:    c.Params.Get("access_token"),
		Path:     "/",
		HttpOnly: true,
		Expires:  time.Now().Add(time.Second * time.Duration(c.Params.Int64("expires_in"))),
	})

	if c.Params.Get("state") != "" {
		c.Redirect(c.Params.Get("state"))
	} else {
		c.Redirect(config.HttpSrvBasePath(""))
	}
}
Example #2
0
func (c Auth) LoginAction() {

	c.AutoRender = false

	referer := config.HttpSrvBasePath("")
	if len(c.Request.Referer()) > 10 {
		referer = c.Request.Referer()
	}

	c.Redirect(idclient.AuthServiceUrl(
		config.Config.InstanceID,
		fmt.Sprintf("//%s%s/auth/cb", c.Request.Host, config.HttpSrvBasePath("")), referer))
}
Example #3
0
func (c Index) IndexAction() {

	c.Data["version"] = config.Config.Version

	//
	if !idclient.SessionIsLogin(c.Session) {
		c.Redirect(idclient.AuthServiceUrl(
			config.Config.InstanceID,
			fmt.Sprintf("//%s%s/auth/cb", c.Request.Host, config.HttpSrvBasePath("")),
			c.Request.RawAbsUrl()))
		return
	}

	//
	c.Data["pandora_endpoint"] = config.Config.PandoraEndpoint
}
Example #4
0
func (c Pod) IndexAction() {

	c.Data["version"] = config.Config.Version

	//
	if !idclient.SessionIsLogin(c.Session) {
		c.Redirect(idclient.AuthServiceUrl(
			config.Config.InstanceID,
			fmt.Sprintf("//%s%s/auth/cb", c.Request.Host, config.HttpSrvBasePath("")),
			c.Request.RawAbsUrl()))
		return
	}

	//
	c.Data["pandora_endpoint"] = config.Config.PandoraEndpoint
	c.Data["l9r_pod_active"] = c.Params.Get("pod_id")

	c.Render("index/index.tpl")
}