Skip to content

Commit 8abc850

Browse files
author
陈弘桂
committedJul 24, 2018
fixed: make auth domain configable
1 parent e5e1f18 commit 8abc850

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed
 

‎auth/auth.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"goAdmin/connections/mysql"
77
"strconv"
88
"time"
9+
"goAdmin/config"
910
)
1011

1112
func Check(password []byte, username string) (user User, ok bool) {
@@ -53,7 +54,7 @@ func SetCookie(ctx *fasthttp.RequestCtx, user User) bool {
5354
var c fasthttp.Cookie
5455
c.SetKey("go_admin_session")
5556
c.SetValue(sessionKey)
56-
c.SetDomain("localhost")
57+
c.SetDomain(config.EnvConfig["AUTH_DOMAIN"].(string))
5758
c.SetExpire(time.Now().Add(time.Hour * 48))
5859
ctx.Response.Header.SetCookie(&c)
5960

@@ -64,7 +65,7 @@ func DelCookie(ctx *fasthttp.RequestCtx) bool {
6465
var c fasthttp.Cookie
6566
c.SetKey("go_admin_session")
6667
c.SetValue("")
67-
c.SetDomain("localhost")
68+
c.SetDomain(config.EnvConfig["AUTH_DOMAIN"].(string))
6869
c.SetExpire(time.Now())
6970
ctx.Response.Header.SetCookie(&c)
7071

‎config/config.go

+2
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ var EnvConfig = map[string]interface{}{
1818
"REDIS_DB": 1,
1919

2020
"PORTABLE": false,
21+
22+
"AUTH_DOMAIN": "localhost",
2123
}

0 commit comments

Comments
 (0)
Please sign in to comment.