Skip to content

Conversation

@gustoliv
Copy link

@gustoliv gustoliv commented Apr 4, 2025

Summary

This PR improves the openidc_get_bearer_access_token function by trimming whitespace from headers and ensuring proper validation of the extracted access token. (Fixes #537)

Changes

  • Added a trim function to remove leading and trailing whitespace from headers before processing.
  • Changed the validation check from nil to "" since header:sub(divider + 1) always return a string.
  • If the token is missing, it will be an empty string ("") rather than nil.
  • This ensures invalid tokens are correctly identified.

Impact

These improvements enhance robustness and prevent potential issues with incorrectly formatted headers.

Test Results

After these changes, the unit tests improved from 498 successes / 11 failures to 503 successes / 0 failures.

Before:

image

After:

image

… space in openidc_get_bearer_access_token
@gustoliv gustoliv changed the title fixes #537: Incorrect Handling of Bearer Token with trailing space in… Incorrect Handling of Bearer Token with trailing space in openidc_get_bearer_access_token Apr 4, 2025
… space in openidc_get_bearer_access_token
@zandbelt zandbelt merged commit fabf64e into zmartzone:master Apr 8, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Handling of Bearer Token with trailing space in openidc_get_bearer_access_token

2 participants