Don't panic if we don't find the nonce in the cache
This commit is contained in:
parent
febc3e4fe3
commit
2d8643d593
7
main.go
7
main.go
|
@ -186,10 +186,13 @@ func redirectIfNoCookie(handler http.Handler, r *http.Request, w http.ResponseWr
|
||||||
|
|
||||||
func getReturnUrl(secret string, payload string, sig string, nonce string) (returnUrl string, err error) {
|
func getReturnUrl(secret string, payload string, sig string, nonce string) (returnUrl string, err error) {
|
||||||
value, gotNonce := nonceCache.Get(nonce)
|
value, gotNonce := nonceCache.Get(nonce)
|
||||||
|
if !gotNonce {
|
||||||
|
err = fmt.Errorf("Nonce %s not found", nonce)
|
||||||
|
return
|
||||||
|
}
|
||||||
returnUrl = value.(string)
|
returnUrl = value.(string)
|
||||||
nonceCache.Remove(nonce)
|
nonceCache.Remove(nonce)
|
||||||
valid := ComputeHmac256(payload, secret) == sig && gotNonce
|
if ComputeHmac256(payload, secret) != sig {
|
||||||
if !valid {
|
|
||||||
err = fmt.Errorf("Signature is invalid")
|
err = fmt.Errorf("Signature is invalid")
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue