Skip to content
This repository was archived by the owner on Feb 14, 2018. It is now read-only.

X-Auth-UserId header should be cleared before attempting authentication #42

@hkarim

Description

@hkarim

Should note in the documentation or the examples that it is safer to clear the X-Auth-UserId header before trying to authenticate the request, something like:

location /secure {
      access_by_lua '
        ngx.req.clear_header("X-Auth-UserId") 
        local jwt = require("nginx-jwt")
        jwt.auth()
      ';
}

Also noticed that the header is being set on the response not the request, shouldn't it be the other way around? So that backends get the authenticated subject. Currently, we have this in our nginx-jwt.lua:

-- write the X-Auth-UserId header
-- ngx.header["X-Auth-UserId"] = jwt_obj.payload.sub
ngx.req.set_header("X-Auth-UserId", jwt_obj.payload.sub)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions