Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Django OAuth Toolkit #90

Open
digoburigo opened this issue Nov 2, 2023 · 1 comment
Open

Support Django OAuth Toolkit #90

digoburigo opened this issue Nov 2, 2023 · 1 comment

Comments

@digoburigo
Copy link

Trying to integrate with Django OAuth Toolkit but I'm getting an error with Zod validation in response_type prop. It seems that the strings are inverted. Is there something wrong with the configuration or it's an unknown error?

web-oidc
  1. "token id_token"
  2. "code token id_token"

django oauth toolkit
  1. "id_token token"
  2. "code id_token token" 

https://django-oauth-toolkit.readthedocs.io/en/latest/settings.html#oidc-response-types-supported

[
    "code",
    "token",
    "id_token",
    "id_token token",
    "code token",
    "code id_token",
    "code id_token token",
]

Zod error:

ZodError: [
  {
    "received": "id_token token",
    "code": "invalid_enum_value",
    "options": [
      "code",
      "token",
      "id_token",
      "code token",
      "code id_token",
      "token id_token",
      "code token id_token",
      "none"
    ],
    "path": [
      "response_types_supported",
      3
    ],
    "message": "Invalid enum value. Expected 'code' | 'token' | 'id_token' | 'code token' | 'code id_token' | 'token id_token' | 'code token id_token' | 'none', received 'id_token token'"
  },
  {
    "received": "code id_token token",
    "code": "invalid_enum_value",
    "options": [
      "code",
      "token",
      "id_token",
      "code token",
      "code id_token",
      "token id_token",
      "code token id_token",
      "none"
    ],
    "path": [
      "response_types_supported",
      7
    ],
    "message": "Invalid enum value. Expected 'code' | 'token' | 'id_token' | 'code token' | 'code id_token' | 'token id_token' | 'code token id_token' | 'none', received 'code id_token token'"
  }
]
    at get error [as error] (file:///Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/zod/lib/index.mjs:538:31)
    at ZodObject.parseAsync (file:///Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/zod/lib/index.mjs:661:22)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Issuer.discover (file:///Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/web-oidc/build/issuer.js:64:20)
    at async OIDCStrategy.authenticate (file:///Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/web-oidc/build/remix.js:23:26)
    at async action (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/apps/remixvite/app/routes/login.tsx:22:10)
    at async Object.callRouteActionRR (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/server-runtime/dist/data.js:35:16)
    at async callLoaderOrAction (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/router/dist/router.cjs.js:4041:16)
    at async submit (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/router/dist/router.cjs.js:3413:16)
    at async queryImpl (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/router/dist/router.cjs.js:3371:22)
    at async Object.queryRoute (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/router/dist/router.cjs.js:3340:18)
    at async handleDataRequestRR (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/server-runtime/dist/server.js:107:20)
    at async requestHandler (/Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/server-runtime/dist/server.js:81:18)
    at async /Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/dev/dist/vite/node/adapter.js:184:20
    at async /Users/rodrigoburigo/Documents/Projects/eTopocart/etopocart-apps/node_modules/@remix-run/dev/dist/vite/plugin.js:413:13
@sergiodxa
Copy link
Owner

It's the Zod configuration being too strict, I used the values from the spec but I suppose inverted ones should also work.

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

No branches or pull requests

2 participants