|
|
@@ -100,6 +100,7 @@ func AddToAuthMap(conn *websocket.Conn, token map[string]string, authed bool) er
|
|
|
// check the validity of the token
|
|
|
func CheckToken(token map[string]string, conn *websocket.Conn, r *http.Request, setup bool) bool {
|
|
|
// great you have token. we see if valid.
|
|
|
+ config.Logger.Info(fmt.Sprintf("Checking token %s",token["id"]))
|
|
|
conf := config.Conf()
|
|
|
key := conf.KeyFile
|
|
|
res, err := KeyfileDecrypt(token["token"], key)
|
|
|
@@ -120,6 +121,7 @@ func CheckToken(token map[string]string, conn *websocket.Conn, r *http.Request,
|
|
|
// you in auth map?
|
|
|
if WsIsAuthenticated(conn, hash) {
|
|
|
if ip == res["ip"] && userAgent == res["user_agent"] {
|
|
|
+ config.Logger.Info("Token authenticated")
|
|
|
return true
|
|
|
} else {
|
|
|
config.Logger.Warn("Token doesn't match session!")
|