Skip to content

support for custom token type#154

Open
dagframstad wants to merge 4 commits into
krakend:masterfrom
dagframstad:issue_153_custom_token_type
Open

support for custom token type#154
dagframstad wants to merge 4 commits into
krakend:masterfrom
dagframstad:issue_153_custom_token_type

Conversation

@dagframstad

@dagframstad dagframstad commented Nov 20, 2025

Copy link
Copy Markdown

Support for custom token type
example config:

...
   "extra_config": {
          "auth/validator": {
            "operation_debug": fale,
            "alg": "RS256",
            "token_type": "DPoP",
            "cache": true,
            "jwk_url": "https://foo.bar/jwk",
            "issuer": "https://foo.bar/",
            "scopes": [
              "org:myscope"
            ],
            "scopes_key": "scope"
          }
        },
...

Solution for issue #153

@thedae

thedae commented Nov 24, 2025

Copy link
Copy Markdown
Member

Hi @dagframstad thanks for your contribution, it's looking rather interesting. We're taking a deep look at your proposal. In the meantime, could you check the Deepsource action failure? https://app.deepsource.com/gh/krakend/krakend-jose/run/97278256-ef64-4c59-b3c9-2c5ec46baeba/go/

Additionally, I'm a bit concerned about changing the signatures of FromHeader and FromCookie functions, as they are public and could potentially introduce breaking changes. In these cases, what we usually recommend is to leave the public function prototypes as they are and create new ones with the desired customization, in this case a pair like FromHeaderWithType(key, type string) and FromCookieWithType(key, type string) (for example).

…ieWithType and FromHeaderWithType with the new type parameter as requested.

Also fixed one of the Deepsource action failures.
@dagframstad

Copy link
Copy Markdown
Author

Hi @thedae , thanks for the feedback. I think this last commit addresses you concerns.
I hope the code is OK, because I am unable to confirm it on my machine, I get the following output when running make (same output on master branch and issue_153_custom_token_type branch):

go generate ./...
2025/11/24 18:02:59 wrote cert.pem
2025/11/24 18:02:59 wrote key.pem
go test ./...
# github.com/krakend/krakend-jose/v2/mux
# [github.com/krakend/krakend-jose/v2/mux]
mux/jose_example_test.go:20:1: Example_RS256 has malformed example suffix: RS256
mux/jose_example_test.go:48:1: Example_HS256 has malformed example suffix: HS256
mux/jose_example_test.go:74:1: Example_HS256_cookie has malformed example suffix: HS256_cookie
# github.com/krakend/krakend-jose/v2/gin
# [github.com/krakend/krakend-jose/v2/gin]
gin/jose_example_test.go:21:1: Example_RS256 has malformed example suffix: RS256
gin/jose_example_test.go:69:1: Example_HS256 has malformed example suffix: HS256
gin/jose_example_test.go:111:1: Example_HS256_cookie has malformed example suffix: HS256_cookie
ok  	github.com/krakend/krakend-jose/v2	5.307s
FAIL	github.com/krakend/krakend-jose/v2/gin [build failed]
FAIL	github.com/krakend/krakend-jose/v2/mux [build failed]
ok  	github.com/krakend/krakend-jose/v2/secrets	(cached)
ok  	github.com/krakend/krakend-jose/v2/tests	0.994s
FAIL
make: *** [test] Error 1

@thedae

thedae commented Nov 25, 2025

Copy link
Copy Markdown
Member

Awesome @dagframstad, thanks for the patch. The team is a bit overloaded right now, but we'll do our best to check and validate this PR as soon as we can

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.

2 participants