Skip to content

Getting error "state not found" #324

Closed
@phxgbl

Description

@phxgbl

I tried example https://github.com/coreos/go-oidc/tree/v3/example/idtoken using dex as the provider.

clientID = "example-app" clientSecret = "ZXhhbXBsZS1hcHAtc2VjcmV0" issuerURL = "http://127.0.0.1:5556/dex"
this is the redirect URL generated : http://127.0.0.1:5556/dex/auth/local/login?back=/dex/auth?client_id=example-app&nonce=y33hX8FTJqMLTiioSqBpCg&redirect_uri=http%3A%2F%2F127.0.0.1%3A3000%2Fauth%2Foidc%2Fcallback&response_type=code&scope=openid+profile+email&state=fL-QEKXmJq5SlP5pwM8YMA&state=i2tdp55gib7izeo7klb2mvjt2

Login using dex static password was successful and redirected back to the client app http://127.0.0.1:3000/auth/oidc/callback?code=xvzekwrtacz5lq7vsbhaoqk3t&state=fL-QEKXmJq5SlP5pwM8YMA with a different state.
before redirect the client app sets Cookie 'state' using function
setCallbackCookie(w, r, "state", state), setCallbackCookie(w, r, "nonce", nonce)
And in callback handler tries to retrieve the same using

state, err := r.Cookie("state") if err != nil { http.Error(w, "state not found", http.StatusBadRequest) return }
but the state gives null. ie, cookie not sent by the browser. any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions