omsec
(Roger)
December 5, 2020, 8:13am
1
I am trying to set and read a secure server-side Cookie. Can’t see what I’m doing wrong. Decoding gives me error securecookie: base64 decode failed - caused by: illegal base64 data at input byte 203
perhaps it’s the % sign at this position
I created a very simple app to demonstrate my problem:
In https://github.com/omsec/cookietest/blob/main/controllers/authentication.go I try to write a
tokens := map[string]string{
"access_token": "test_at",
"refresh_token": "test_rt"}
in the “Login” function and then read it in the “GetSomething” handler function.
The actual cookie stuff is encapsulated here:
package helpers
import (
"fmt"
"net/http"
"github.com/gin-gonic/gin"
"github.com/gorilla/securecookie"
)
// SetCookie writes a cookie
func SetCookie(c *gin.Context, name string, value interface{}) error {
var sck = securecookie.New([]byte("thisIsExactly32BytesLongYeah1234"), []byte("thisIsExactly32BytesLongYeah1234"))
encoded, err := sck.Encode(name, value)
if err != nil {
return err
}
This file has been truncated. show original
Error occurs in “GetCookie” Line 48
Am I doing it wrong?
omsec
(Roger)
December 6, 2020, 8:38am
2
Well I’m not saying this is a bug, since I’m no expert, just a GO beginner…
I switched to this implementation and it works as intended:
system
(system)
Closed
March 6, 2021, 8:39am
3
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.