Skip to content

Document issues using if and return with headers #100

@pgthompson24

Description

@pgthompson24

Hello, I am currently looking to only allow a particular user (JWT subject) to access a specific endpoint on my web server. So I am using the following configuration to do so:

        location /endpoint {
            proxy_set_header Host $http_host;
            auth_jwt_enabled on;
            auth_jwt_algorithm RS384;
            auth_jwt_validate_sub on;
            auth_jwt_extract_request_claims sub;
            if ($http_jwt_sub != "super-user") {
                return 401 [$http_jwt_sub];
            }
            auth_jwt_use_keyfile on;
            auth_jwt_keyfile_path "<mysecretlocation>";
            auth_jwt_location COOKIE=token;
            proxy_pass http://localhost:3000;

        }

This configuration works without the bit where I try to validate the claims. It even allows access with the auth_jwt_validate_sub on; config. It validates the sub exists but my page yields empty brackets [] on return (i.e. the $http_jwt_sub variable is empty). I have tested and found that it fails to extract any values for other parameters of my JWT payload as well. And I can confirm that my JWT does in fact contain these fields:
image

Has anyone else experienced this or is there some syntax I am not following properly?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions