mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
add sso
This commit is contained in:
parent
c7d8d33e2c
commit
efd2eb3c08
@ -135,7 +135,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 请求地址
|
// 请求地址
|
||||||
msg.Option(ice.MSG_USERWEB, kit.Select(msg.Config(DOMAIN), kit.Select(r.Header.Get("X-Host"), r.Header.Get("Referer"))))
|
msg.Option(ice.MSG_USERWEB, kit.Select(msg.Config(DOMAIN), kit.Select(r.Header.Get("Referer"), r.Header.Get("X-Host"))))
|
||||||
msg.Option(ice.MSG_USERADDR, kit.Select(r.RemoteAddr, r.Header.Get(ice.MSG_USERADDR)))
|
msg.Option(ice.MSG_USERADDR, kit.Select(r.RemoteAddr, r.Header.Get(ice.MSG_USERADDR)))
|
||||||
msg.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
|
msg.Option(ice.MSG_USERIP, r.Header.Get(ice.MSG_USERIP))
|
||||||
msg.Option(ice.MSG_USERUA, r.Header.Get("User-Agent"))
|
msg.Option(ice.MSG_USERUA, r.Header.Get("User-Agent"))
|
||||||
@ -145,6 +145,7 @@ func _serve_handle(key string, cmd *ice.Command, msg *ice.Message, w http.Respon
|
|||||||
if sessid := msg.Option(CookieName(msg.Option(ice.MSG_USERWEB))); sessid != "" {
|
if sessid := msg.Option(CookieName(msg.Option(ice.MSG_USERWEB))); sessid != "" {
|
||||||
msg.Option(ice.MSG_SESSID, sessid)
|
msg.Option(ice.MSG_SESSID, sessid)
|
||||||
}
|
}
|
||||||
|
msg.Debug("what %v", msg.FormatMeta())
|
||||||
|
|
||||||
// 参数转换
|
// 参数转换
|
||||||
for k, v := range r.Form {
|
for k, v := range r.Form {
|
||||||
|
@ -86,6 +86,10 @@ func init() {
|
|||||||
}, Commands: map[string]*ice.Command{
|
}, Commands: map[string]*ice.Command{
|
||||||
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
web.WEB_LOGIN: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
switch arg[0] {
|
switch arg[0] {
|
||||||
|
case "/sso/":
|
||||||
|
if m.Option(ice.MSG_USERNAME) != "" {
|
||||||
|
return
|
||||||
|
}
|
||||||
case "/pod/":
|
case "/pod/":
|
||||||
return // 免登录
|
return // 免登录
|
||||||
case "/header":
|
case "/header":
|
||||||
|
25
core/chat/sso.go
Normal file
25
core/chat/sso.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package chat
|
||||||
|
|
||||||
|
import (
|
||||||
|
ice "shylinux.com/x/icebergs"
|
||||||
|
"shylinux.com/x/icebergs/base/aaa"
|
||||||
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/web"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
|
)
|
||||||
|
|
||||||
|
const SSO = "sso"
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
Index.Merge(&ice.Context{Commands: map[string]*ice.Command{
|
||||||
|
"/sso": {Name: "/sso", Help: "登录", Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||||
|
sessid := m.Cmdx(web.SPACE, m.Option(web.SPACE), aaa.SESS, mdb.CREATE,
|
||||||
|
mdb.TIME, m.Time("720h"),
|
||||||
|
aaa.USERROLE, m.Option(ice.MSG_USERROLE),
|
||||||
|
aaa.USERNAME, m.Option(ice.MSG_USERNAME),
|
||||||
|
aaa.USERNICK, m.Option(ice.MSG_USERNICK),
|
||||||
|
)
|
||||||
|
m.RenderRedirect(kit.MergeURL(m.Option("back"), ice.MSG_SESSID, sessid))
|
||||||
|
}},
|
||||||
|
}})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user