#Secure attributes cookie

40 messages · Page 1 of 1 (latest)

distant lichen
#

from the cookies rfc6265

5.  The Secure Attribute

   The Secure attribute limits the scope of the cookie to "secure"
   channels (where "secure" is defined by the user agent).  When a
   cookie has the Secure attribute, the user agent will include the
   cookie in an HTTP request only if the request is transmitted over a
   secure channel (typically HTTP over Transport Layer Security (TLS)

So is the user client who decides what a secure Chanel is. For browser yes, https is a secure Chanel

silk burrow
#

when i enable secure my cookie do not appear?

  1. Define do not appear, is it not showing on your response header? request header? or you just cannot check the value in brower?

why it is because im in localhost and it is not https?

  1. If you are accessing localhost, most browser will send secure cookies even you are on http. It is completely depends on your browser. And for some browser you may need to enable develop settings manually.
old flower
#

you can have a dev mode for local where you don't set Secure

boreal iron
silk burrow
#

how do you know it's not set

#

it may be set but just you are detecting it incorrectly.

#

just share your whole program and full steps to reproduce & observe the result

boreal iron
silk burrow
#

so what browser are you using

boreal iron
#

safari

silk burrow
#

go check the request headers

#

I'd say if possible just switch to chrome ...

boreal iron
#

i will try chrome

silk burrow
#

unless you were talking response header

boreal iron
boreal iron
#
func NewSubrouter(prefix string, mux *http.ServeMux, mw ...Middleware) *Subrouter {
    return &Subrouter{prefix: prefix, mux: mux, middlewares: mw}
}

// Apply middleware in reverse order (like a stack)
func (s *Subrouter) applyMiddleware(h http.Handler) http.Handler {
    for i := len(s.middlewares) - 1; i >= 0; i-- {
        h = s.middlewares[i](h)
    }
    return h
}

// Register route with middleware applied
func (s *Subrouter) HandleFunc(pattern string, handlerFunc http.HandlerFunc) {
    path := s.prefix + pattern
    h := s.applyMiddleware(handlerFunc)
    s.mux.Handle(path, h)
}
silk burrow
#

I can help nothing unless you state your problem

#

also it's better to open another post

boreal iron
#
func routing() http.Handler {
    mux := http.NewServeMux()
    mux.HandleFunc("GET /", Home)

    mux.HandleFunc("GET /signup", SignUp)
    mux.HandleFunc("POST /signup", PostSignup)

    mux.HandleFunc("GET /signin", SignIn)
    mux.HandleFunc("POST /signin", PostSignIn)

    mux.HandleFunc("GET /signout", SignOut)

    mw := []Middleware{
        VerifyCsrfMiddleware,
    }
    app := NewSubrouter("app", mux, mw...)
    app.HandleFunc("GET /", App)

    // Apply middleware chain globally
    // mux.Handle("/home", AuthMiddleware(http.HandlerFunc(Home)))
    return MiddlewaresChain(mux, VerifyCsrfMiddleware)
}
#

sorry i was rewriting the code

#

when i go to app/ it work

#

when i redirect to app/

#

it say method not allowed

#

http.Redirect(w, r, "app/", http.StatusPermanentRedirect)

boreal iron
silk burrow
#

when i redirect to app/
Redirect from where?
it say method not allowed
Which method are you using? What is your current path?

boreal iron
silk burrow
#

so which path is your browser showing after the redirect?

boreal iron
#

but when i reload this path it work

silk burrow
#

so you are redirecting to POST?

#

either way

#
    app := NewSubrouter("app", mux, mw...)
    app.HandleFunc("GET /", App)
path := s.prefix + pattern

which means

path := "app" + "GET /"
path == "appGET /"
boreal iron
silk burrow
#

I don't think there is a method called "appGET"