Skip to content

Not able to use variables for if-statements or in redirect uris #112

@mariosdimitradis

Description

@mariosdimitradis

First of all, thank you for this module.
I currently facing some issues and need some help to make it work for me.

The JWT-Token looks like this:
Header:

{
  "typ": "JWT",
  "alg": "RS256"
}

Payload:

{
  "exp": 1698974933,
  "iat": 1698938933,
  "scope": "read write",
  "custgroup": "B2B, PreSale"
  ...
}

The Nginx vHost configurations looks like this:

location / {
  auth_jwt_location HEADER=Authorization;
  auth_jwt_enabled on;
  auth_jwt_algorithm RS256;
  auth_jwt_use_keyfile on;
  auth_jwt_keyfile_path /etc/nginx/jwtPub.key;
  auth_jwt_extract_request_claims custgroup;
}

This is working fine without any issues.
When I try to access $http_jwt_custgroup in if-statement or return it is not working.

Example:

location / {
  ...
  return 307 /$http_jwt_custgroup;
  ...
}
location / {
  ...
  if ($http_jwt_custgroup ~* "B2B") {
    return 307 /b2b-access;
  }
  ...
}

The above http_jwt_* variables works also can be also added to the header with add_header.
I also tried to set a new variable with set $myVar $http_jwt_custgroup;, but also not working.

Are any limitations? The Example from the README.md file is also not working for me.

location /profile/me {
    auth_jwt_extract_request_claims sub;

    return 301 /profile/$http_jwt_sub;
}

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