This repository has been archived on 2023-07-09. You can view files and clone it, but cannot push or open issues or pull requests.
sudoscientist-go-backend/packages/middleware/auth_middleware.go

25 lines
441 B
Go
Raw Normal View History

2019-10-06 02:35:14 +00:00
package auth_middleware
import (
"net/http"
2020-01-21 01:06:32 +00:00
"path"
2019-10-06 02:35:14 +00:00
)
func TokenFromSplitCookie(r *http.Request) string {
dataCookie, err := r.Cookie("DataCookie")
if err != nil {
return ""
}
signatureCookie, err := r.Cookie("SignatureCookie")
if err != nil {
return ""
}
cookie := dataCookie.Value + "." + signatureCookie.Value
return cookie
}
2020-01-21 01:06:32 +00:00
func TokenFromUrl(r *http.Request) string {
_, token := path.Split(r.URL.Path)
return token
}