From ac3a2c32b5684ea8338bad7e28ac5fad131fac0d Mon Sep 17 00:00:00 2001 From: Simon Eisenmann Date: Fri, 28 Mar 2014 16:20:09 +0100 Subject: [PATCH] Use expiration time stamp for TURN REST API auth. --- src/app/spreed-speakfreely-server/hub.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/spreed-speakfreely-server/hub.go b/src/app/spreed-speakfreely-server/hub.go index e38aa096..c11a0931 100644 --- a/src/app/spreed-speakfreely-server/hub.go +++ b/src/app/spreed-speakfreely-server/hub.go @@ -146,12 +146,12 @@ func (h *Hub) CreateTurnData(id string) *DataTurn { bar.Write([]byte(id)) id = base64.StdEncoding.EncodeToString(bar.Sum(nil)) foo := hmac.New(sha1.New, h.turnSecret) - now := int32(time.Now().Unix()) + expiration := int32(time.Now().Unix())+turnTTL switch h.turnUsernameFormat { case "time:id": - user = fmt.Sprintf("%d:%s", now, id) + user = fmt.Sprintf("%d:%s", expiration, id) default: - user = fmt.Sprintf("%s:%d", id, now) + user = fmt.Sprintf("%s:%d", id, expiration) } foo.Write([]byte(user)) password := base64.StdEncoding.EncodeToString(foo.Sum(nil))