Skip to content

Can not get OIDC token from NSS via @inrupt/generate-oidc-token #1580

Closed

Description

@jeff-zucker

Note: this is about getting an OIDC token from NSS as an IDP, not about getting a token after logging in with username/password.

I tried running @inrupt/generate-oidc-token against both solidcommunity.net and solidcommunity.net:8443 with the same results : I was able to get a link for the browser login page, log in manually, but then got the below on the console instead of the JSON for the token. @NSeydoux - not sure if this is a bug in @inrupt/generate-oidc-token or in NSS. Note, that it tells me that login was successful.

Login successful.
(node:964489) DraftWarning: The DPoP APIs implements an IETF draft. Breaking draft implementations are included as minor versions of the openid-client library, therefore, the ~ semver operator should be used and close attention be payed to library changelog as well as the drafts themselves.
(Use `node --trace-warnings ...` to show where the warning was created)
(node:964489) UnhandledPromiseRejectionWarning: OPError: invalid_grant (Mismatching redirect uri)
    at processResponse (/home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/openid-client/lib/helpers/process_response.js:45:13)
    at Client.grant (/home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/openid-client/lib/client.js:1237:26)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async Client.callback (/home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/openid-client/lib/client.js:460:24)
    at async AuthCodeRedirectHandler.handle (/home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/@inrupt/solid-client-authn-node/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js:77:24)
    at async ClientAuthentication.handleIncomingRedirect (/home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/@inrupt/solid-client-authn-node/dist/ClientAuthentication.js:70:34)
    at async Session.handleIncomingRedirect (/home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/@inrupt/solid-client-authn-node/dist/Session.js:45:35)
    at async /home/jeff/Dropbox/Web/solid/solid-node-client/node_modules/@inrupt/generate-oidc-token/dist/index.js:82:9
(node:964489) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:964489) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Activity

  1. NSeydoux commented on Mar 8, 2021

    @NSeydoux

    The fact that it displays that the login is successful, when it visibly isn't, looks like an @inrupt/generate-oidc-token issue. However, I'm not sure where the "main" issue is coming from. As far as I can tell, the OIDC provider should check that the redirect URI provided at the authorization endpoint matches the one provided during Dynamic Client Registration. In the case of @inrupt/generate-oidc-token, which wraps @inrupt/solid-client-authn-browser, these URIs both come from the login call parameter, so they should match. I tried reproducing the bug this morning, and here is the output I got:

    >_ npx @inrupt/generate-oidc-token
    Need to install the following packages:
      @inrupt/generate-oidc-token
    Ok to proceed? (y) 
    ? What Solid Identity Provider do you want to register your app to? My Solid Identity provider is not on the list - please contact 'developer-support@inrupt.com' if you'd like to discuss adding a new provider.
    ? What is the URL of the Solid Identity Provider you wish to register your application with? https://solidcommunity.net
    ? Do you want your app to go through static, or dynamic registration? Dynamic: less configuration, but credentials expire quicker.
    ? What is the name of the application you are registering? Test app
    ? @inrupt/generate-oidc-token will start a local web server, in order for the Solid Identity Provider to redirect the user back after they log in. To what port should this local server be bound? 3001
    Listening at: [http://localhost:3001].
    Logging into Solid Identity Provider  https://solidcommunity.net to get a refresh token.
    
    Please visit https://solidcommunity.net/authorize?client_id=<some client ID>&scope=openid%20offline_access&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3001&code_challenge=<some code challenge>&code_challenge_method=S256 in a web browser.
    
    Login successful.
    (node:19380) DraftWarning: The DPoP APIs implements an IETF draft. Breaking draft implementations are included as minor versions of the openid-client library, therefore, the ~ semver operator should be used and close attention be payed to library changelog as well as the drafts themselves.
    
    Refresh token: [<a refresh token>]
    Client ID: [<some client ID>]
    Client Secret: [<some client secret>]
    

    Using this token if currently still unsuccessful due to nodeSolidServer/oidc-op#32, but I don't get the same issue as you. Could you detail the steps to reproduce ?

  2. jeff-zucker commented on Mar 8, 2021

    @jeff-zucker
    MemberAuthor

    Here's what I did and what I got ... details of my setup below that

    npx @inrupt/generate-oidc-token
    ? What Solid Identity Provider do you want to log in to? My Solid Identity provi
    der is not on the list - please contact 'developer-support@inrupt.com' if you'd 
    like to discuss adding a new provider.
    ? What is the URL of the Solid Identity Provider you wish to log in to? https://
    solidcommunity.net
    ? Has your app been pre-registered by the administrator of the Pod server you ar
    e signing in to? No.
    ? What is the name of the application you are registering? jztest
    ? @inrupt/generate-oidc-token will start a local web server, to which the Solid 
    Identity Provider can redirect the user back after they log in. On what port do 
    you want to run this server? 3001
    Listening at: [http://localhost:3001].
    Logging in to Solid Identity Provider  https://solidcommunity.net to get a refresh token.
    
    Please visit https://solidcommunity.net/authorize?client_id=87df5075aeef43ca5cfdde686b571252&scope=openid%20offline_access&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3001&code_challenge=wUFG-EI_6xWANQn0UfAF7iszynAgbB8Soi7NolYXpCI&state=jr10Z7wdfIm2lpf3QyV1yKYRO21-nyV38MJpfYxV46A&code_challenge_method=S256 in a web browser.
    
    Login successful.
    (node:1088142) DraftWarning: The DPoP APIs implements an IETF draft. Breaking draft implementations are included as minor versions of the openid-client library, therefore, the ~ semver operator should be used and close attention be payed to library changelog as well as the drafts themselves.
    (Use `node --trace-warnings ...` to show where the warning was created)
    (node:1088142) UnhandledPromiseRejectionWarning: OPError: invalid_grant (Mismatching redirect uri)
        at processResponse (/home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/openid-client/lib/helpers/process_response.js:45:13)
        at Client.grant (/home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/openid-client/lib/client.js:1237:26)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
        at async Client.callback (/home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/openid-client/lib/client.js:460:24)
        at async AuthCodeRedirectHandler.handle (/home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/@inrupt/solid-client-authn-node/dist/login/oidc/redirectHandler/AuthCodeRedirectHandler.js:77:24)
        at async ClientAuthentication.handleIncomingRedirect (/home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/@inrupt/solid-client-authn-node/dist/ClientAuthentication.js:70:34)
        at async Session.handleIncomingRedirect (/home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/@inrupt/solid-client-authn-node/dist/Session.js:45:35)
        at async /home/jeff/Dropbox/Web/solid/generate-oidc-token/node_modules/@inrupt/generate-oidc-token/dist/index.js:82:9
    (node:1088142) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
    (node:1088142) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
    

    Here is my setup : Linux Mint 20.04, node v14.15.1, npm 6.14.8

    └─┬ @inrupt/generate-oidc-token@0.1.0
      ├─┬ @inrupt/solid-client-authn-node@1.7.1
      │ ├─┬ @inrupt/solid-client-authn-core@1.7.1
      │ │ ├─┬ @inrupt/solid-common-vocab@0.5.3
      │ │ │ └─┬ @types/rdf-js@4.0.0
      │ │ │   └── @types/node@14.14.32 deduped
      │ │ ├─┬ @types/lodash.clonedeep@4.5.6
      │ │ │ └── @types/lodash@4.14.168
      │ │ ├── @types/uuid@8.3.0 deduped
      │ │ ├─┬ ajv@6.12.6
      │ │ │ ├── fast-deep-equal@3.1.3
      │ │ │ ├── fast-json-stable-stringify@2.1.0
      │ │ │ ├── json-schema-traverse@0.4.1
      │ │ │ └─┬ uri-js@4.4.1
      │ │ │   └── punycode@2.1.1
      │ │ ├── cross-fetch@3.0.6 deduped
      │ │ ├── lodash.clonedeep@4.5.0
      │ │ └── uuid@8.3.2 deduped
      │ ├── @types/node@14.14.32
      │ ├── @types/uuid@8.3.0
      │ ├─┬ cross-fetch@3.0.6
      │ │ └── node-fetch@2.6.1
      │ ├─┬ jose@2.0.4
      │ │ └── @panva/asn1.js@1.0.0
      │ ├─┬ openid-client@4.4.2
      │ │ ├─┬ aggregate-error@3.1.0
      │ │ │ ├── clean-stack@2.2.0
      │ │ │ └── indent-string@4.0.0
      │ │ ├─┬ got@11.8.2
      │ │ │ ├── @sindresorhus/is@4.0.0
      │ │ │ ├─┬ @szmarczak/http-timer@4.0.5
      │ │ │ │ └── defer-to-connect@2.0.1
      │ │ │ ├─┬ @types/cacheable-request@6.0.1
      │ │ │ │ ├── @types/http-cache-semantics@4.0.0
      │ │ │ │ ├─┬ @types/keyv@3.1.1
      │ │ │ │ │ └── @types/node@14.14.32 deduped
      │ │ │ │ ├── @types/node@14.14.32 deduped
      │ │ │ │ └── @types/responselike@1.0.0 deduped
      │ │ │ ├─┬ @types/responselike@1.0.0
      │ │ │ │ └── @types/node@14.14.32 deduped
      │ │ │ ├── cacheable-lookup@5.0.4
      │ │ │ ├─┬ cacheable-request@7.0.1
      │ │ │ │ ├─┬ clone-response@1.0.2
      │ │ │ │ │ └── mimic-response@1.0.1
      │ │ │ │ ├─┬ get-stream@5.2.0
      │ │ │ │ │ └─┬ pump@3.0.0
      │ │ │ │ │   ├─┬ end-of-stream@1.4.4
      │ │ │ │ │   │ └── once@1.4.0 deduped
      │ │ │ │ │   └─┬ once@1.4.0
      │ │ │ │ │     └── wrappy@1.0.2
      │ │ │ │ ├── http-cache-semantics@4.1.0
      │ │ │ │ ├─┬ keyv@4.0.3
      │ │ │ │ │ └── json-buffer@3.0.1
      │ │ │ │ ├── lowercase-keys@2.0.0 deduped
      │ │ │ │ ├── normalize-url@4.5.0
      │ │ │ │ └── responselike@2.0.0 deduped
      │ │ │ ├─┬ decompress-response@6.0.0
      │ │ │ │ └── mimic-response@3.1.0
      │ │ │ ├─┬ http2-wrapper@1.0.3
      │ │ │ │ ├── quick-lru@5.1.1
      │ │ │ │ └── resolve-alpn@1.0.0
      │ │ │ ├── lowercase-keys@2.0.0
      │ │ │ ├── p-cancelable@2.0.0
      │ │ │ └─┬ responselike@2.0.0
      │ │ │   └── lowercase-keys@2.0.0 deduped
      │ │ ├── jose@2.0.4 deduped
      │ │ ├─┬ lru-cache@6.0.0
      │ │ │ └── yallist@4.0.0
      │ │ ├── make-error@1.3.6
      │ │ ├── object-hash@2.1.1
      │ │ └── oidc-token-hash@5.0.1
      │ ├── reflect-metadata@0.1.13
      │ ├─┬ tsyringe@4.4.0
      │ │ └── tslib@1.14.1
      │ └── uuid@8.3.2
      ├─┬ express@4.17.1
      │ ├─┬ accepts@1.3.7
      │ │ ├─┬ mime-types@2.1.29
      │ │ │ └── mime-db@1.46.0
      │ │ └── negotiator@0.6.2
      │ ├── array-flatten@1.1.1
      │ ├─┬ body-parser@1.19.0
      │ │ ├── bytes@3.1.0
      │ │ ├── content-type@1.0.4 deduped
      │ │ ├── debug@2.6.9 deduped
      │ │ ├── depd@1.1.2 deduped
      │ │ ├─┬ http-errors@1.7.2
      │ │ │ ├── depd@1.1.2 deduped
      │ │ │ ├── inherits@2.0.3
      │ │ │ ├── setprototypeof@1.1.1 deduped
      │ │ │ ├── statuses@1.5.0 deduped
      │ │ │ └── toidentifier@1.0.0
      │ │ ├─┬ iconv-lite@0.4.24
      │ │ │ └── safer-buffer@2.1.2
      │ │ ├── on-finished@2.3.0 deduped
      │ │ ├── qs@6.7.0 deduped
      │ │ ├─┬ raw-body@2.4.0
      │ │ │ ├── bytes@3.1.0 deduped
      │ │ │ ├── http-errors@1.7.2 deduped
      │ │ │ ├── iconv-lite@0.4.24 deduped
      │ │ │ └── unpipe@1.0.0 deduped
      │ │ └── type-is@1.6.18 deduped
      │ ├─┬ content-disposition@0.5.3
      │ │ └── safe-buffer@5.1.2 deduped
      │ ├── content-type@1.0.4
      │ ├── cookie@0.4.0
      │ ├── cookie-signature@1.0.6
      │ ├─┬ debug@2.6.9
      │ │ └── ms@2.0.0
      │ ├── depd@1.1.2
      │ ├── encodeurl@1.0.2
      │ ├── escape-html@1.0.3
      │ ├── etag@1.8.1
      │ ├─┬ finalhandler@1.1.2
      │ │ ├── debug@2.6.9 deduped
      │ │ ├── encodeurl@1.0.2 deduped
      │ │ ├── escape-html@1.0.3 deduped
      │ │ ├── on-finished@2.3.0 deduped
      │ │ ├── parseurl@1.3.3 deduped
      │ │ ├── statuses@1.5.0 deduped
      │ │ └── unpipe@1.0.0
      │ ├── fresh@0.5.2
      │ ├── merge-descriptors@1.0.1
      │ ├── methods@1.1.2
      │ ├─┬ on-finished@2.3.0
      │ │ └── ee-first@1.1.1
      │ ├── parseurl@1.3.3
      │ ├── path-to-regexp@0.1.7
      │ ├─┬ proxy-addr@2.0.6
      │ │ ├── forwarded@0.1.2
      │ │ └── ipaddr.js@1.9.1
      │ ├── qs@6.7.0
      │ ├── range-parser@1.2.1
      │ ├── safe-buffer@5.1.2
      │ ├─┬ send@0.17.1
      │ │ ├── debug@2.6.9 deduped
      │ │ ├── depd@1.1.2 deduped
      │ │ ├── destroy@1.0.4
      │ │ ├── encodeurl@1.0.2 deduped
      │ │ ├── escape-html@1.0.3 deduped
      │ │ ├── etag@1.8.1 deduped
      │ │ ├── fresh@0.5.2 deduped
      │ │ ├── http-errors@1.7.2 deduped
      │ │ ├── mime@1.6.0
      │ │ ├── ms@2.1.1
      │ │ ├── on-finished@2.3.0 deduped
      │ │ ├── range-parser@1.2.1 deduped
      │ │ └── statuses@1.5.0 deduped
      │ ├─┬ serve-static@1.14.1
      │ │ ├── encodeurl@1.0.2 deduped
      │ │ ├── escape-html@1.0.3 deduped
      │ │ ├── parseurl@1.3.3 deduped
      │ │ └── send@0.17.1 deduped
      │ ├── setprototypeof@1.1.1
      │ ├── statuses@1.5.0
      │ ├─┬ type-is@1.6.18
      │ │ ├── media-typer@0.3.0
      │ │ └── mime-types@2.1.29 deduped
      │ ├── utils-merge@1.0.1
      │ └── vary@1.1.2
      ├─┬ inquirer@7.3.3
      │ ├─┬ ansi-escapes@4.3.1
      │ │ └── type-fest@0.11.0
      │ ├─┬ chalk@4.1.0
      │ │ ├─┬ ansi-styles@4.3.0
      │ │ │ └─┬ color-convert@2.0.1
      │ │ │   └── color-name@1.1.4
      │ │ └─┬ supports-color@7.2.0
      │ │   └── has-flag@4.0.0
      │ ├─┬ cli-cursor@3.1.0
      │ │ └─┬ restore-cursor@3.1.0
      │ │   ├─┬ onetime@5.1.2
      │ │   │ └── mimic-fn@2.1.0
      │ │   └── signal-exit@3.0.3
      │ ├── cli-width@3.0.0
      │ ├─┬ external-editor@3.1.0
      │ │ ├── chardet@0.7.0
      │ │ ├── iconv-lite@0.4.24 deduped
      │ │ └─┬ tmp@0.0.33
      │ │   └── os-tmpdir@1.0.2
      │ ├─┬ figures@3.2.0
      │ │ └── escape-string-regexp@1.0.5
      │ ├── lodash@4.17.21
      │ ├── mute-stream@0.0.8
      │ ├── run-async@2.4.1
      │ ├─┬ rxjs@6.6.6
      │ │ └── tslib@1.14.1 deduped
      │ ├─┬ string-width@4.2.2
      │ │ ├── emoji-regex@8.0.0
      │ │ ├── is-fullwidth-code-point@3.0.0
      │ │ └── strip-ansi@6.0.0 deduped
      │ ├─┬ strip-ansi@6.0.0
      │ │ └── ansi-regex@5.0.0
      │ └── through@2.3.8
      └─┬ yargs@16.2.0
        ├─┬ cliui@7.0.4
        │ ├── string-width@4.2.2 deduped
        │ ├── strip-ansi@6.0.0 deduped
        │ └─┬ wrap-ansi@7.0.0
        │   ├── ansi-styles@4.3.0 deduped
        │   ├── string-width@4.2.2 deduped
        │   └── strip-ansi@6.0.0 deduped
        ├── escalade@3.1.1
        ├── get-caller-file@2.0.5
        ├── require-directory@2.1.1
        ├── string-width@4.2.2 deduped
        ├── y18n@5.0.5
        └── yargs-parser@20.2.6
    
  3. NSeydoux commented on Mar 10, 2021

    @NSeydoux

    I'm not sure how the bug got initially introduced, but I think I figured out a fix @jeff-zucker. I think we can close this issue and follow up in either inrupt/solid-client-authn-js#1159 or https://github.com/inrupt/generate-oidc-token/issues, and close this issue, because the problem isn't related to the server :).

    Thanks for reporting this !

  4. jeff-zucker commented on Mar 11, 2021

    @jeff-zucker
    MemberAuthor

    @NSeydoux fixed this on the client end, getting an OIDC token issued and logging in with it rather than username/password now works with ISCAN and Solid-Node-Client using ISCAN against the test server (8443)

  5. jeff-zucker commented on Mar 12, 2021

    @jeff-zucker
    MemberAuthor

    Tested from solid-node-client using a generated OIDC token on 5.6.6. - works great now.

  6. bourgeoa commented on Mar 13, 2021

    @bourgeoa
    Member

    @jeff-zucker
    Could you give me an example how to acquire and use the refresh token ?
    and for what kind of process it is needed ?
    I think I do not have enough background on the authentification process.

  7. jeff-zucker commented on Mar 13, 2021

    @jeff-zucker
    MemberAuthor

    @bourgeoa - the basic idea is that logging in to a server from the command line with a username and password is insecure because the password travels unencrypted. With a token, you never send the actual password, only the token. You can acquire the token either using @inrupt/generate-oidc-token or solid-node-client which calls it behind the scenes. Make sure to have latest solid-node-client, solid-client-authn-node, and generate-oidc-token. The instructions are in the solid-node-client README. Basically it is a script that you run from the console that gives a URL which you open in a browser, login to the IDP, and then the token is sent back to the console. You can then copy and paste the JSON for the token either into a storage vault or directly as the login parameter of a call to login. After that everything is the same as if you had logged in from the command line with username/password. The token lasts about three days, though there are plans to make it last longer. Of course, @NSeydoux can give a better explanation since he actually understands the process. :-)

  8. jeff-zucker commented on Mar 13, 2021

    @jeff-zucker
    MemberAuthor

    With ESS (and I believe CSS and Trinpod as well), the OIDC-token is the only way to login outside a browser - there is no username/password flow outside the browser. It would be worth considering if NSS should eventually deprecate using username/password outside the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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