Giter Site home page Giter Site logo

Document OIDC variables about readflow HOT 9 CLOSED

mpldr avatar mpldr commented on May 18, 2024
Document OIDC variables

from readflow.

Comments (9)

ncarlier avatar ncarlier commented on May 18, 2024 1

Hi, you are right: it is set during the build time: see REACT_APP_CLIENT_ID configuration variable on the README page.
But it's true this should be more dynamic. I will try to improve this. Using Docker I can try to create a specific entrypoint managing this.

from readflow.

ncarlier avatar ncarlier commented on May 18, 2024

With the last update you can configure the client_id at runtime using this configuration. This only works if the UI is served by the main process (https://github.com/ncarlier/readflow/blob/master/pkg/config/defaults.toml#L78).

from readflow.

mpldr avatar mpldr commented on May 18, 2024

Thanks a bunch! Gave it a spin and there seems to be an issue with the processing of the provider URL. Invalid response Content-Type: https://id.moritz.sh/application/o/readflow is turned into https://id.moritz.sh/application/o/readflow/ /.well-known/openid-configuration

from readflow.

mpldr avatar mpldr commented on May 18, 2024

Found the issue, it's in the generated config.js:

const __READFLOW_CONFIG__ = {
    // API base URL, default if empty
    // Values: URL (ex: `https://api.readflow.ap`)
    // Default: ''
    // Default can be overridden by setting ${REACT_APP_API_ROOT} env variable during build time
    apiBaseUrl: 'http://localhost:8080',
    // Authorithy, default if empty
    // Values: URL if using OIDC (ex: `https://accounts.readflow.app`), `none` otherwise
    // Default: `none`
    // Default can be overridden by setting ${REACT_APP_AUTHORITY} env variable during build time
    authority: ' https://id.moritz.sh/application/o/readflow/ ',
    // OpenID Connect client ID, default if empty
    // Values: string (ex: `[email protected]`)
    // Default: ''
    // Default can be overridden by setting ${REACT_APP_CLIENT_ID} env variable during build time
    client_id: 'omitted',
}

The issue being rather obvious.

from readflow.

mpldr avatar mpldr commented on May 18, 2024

Can confirm that login succeeds, but I have no idea what access token readflow is saving. It certainly isn't the ID token my identity server sent. It's significantly shorter and obviously corrupt, when trying to parse it.

The server sent:

eyJhbGciOiJSUzI1NiIsImtpZCI6IjBiZDljYzEwY2Q2ZGUwOWI5MTIxYTdkNDNmOGM5NzQ5IiwidHlwIjoiSldUIn0.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YtBYCXSrBVl3tm9-sn64B---5bJ6ZH5vaNRIanEhJ5dQr3n0UqaE0O-g8VnTMWIh17XoJLFd5xmKztEtItXbWBI-qG4JfOfTyRU8jj5Ip_EH8zxZKbL2dPie6Ubf07-zEFsPFTgPcR0FMmj9HhpIbSTeb7sJKsoE9w-dXkKqTQXdPwz-8VOZiTHOqVnSxF-ZCHGts-9TW7waVy8_WnnkeshH3aXNHNEw8rF-boQ9m3uWHkKx6ag-jC2ifyr3jHqxQi6wtNh-TOeVYmF3-xNWxdtnEdnF_tsnG52MMnnwxSD4GhndlvSLSLG-SizsdseucCKmjI

The token stored in the session is correct, as far as I can tell.

The corruption looks to me like it's trying to string-encode the payload, but I can't say where in the program this corruption happens.

from readflow.

mpldr avatar mpldr commented on May 18, 2024

Looking at the frontend code, it also looks like it's trying to pass the access token, but the ID token is the one containing ID part of the OIDC. Not good with JS, so I might be misreading things here, though.

from readflow.

ncarlier avatar ncarlier commented on May 18, 2024

Sorry about the white space problem. I'll fix it.
Your access token is not corrupted but you have a "..." in the middle. This may be the result of a copy/paste from the Developer Console.
Regarding the cinematic: The frontend simply sends the access_token to the backend. The backend is expecting a JWT access_token. Its payload signature is validated. Its content is then decoded. The backend tries to extract the email or preferred_username claim (or falls back on the ìss claim) to use as the readflow username.
This is simple and efficient, but not suitable when using an opaque or "non-tunable" JWT access_token. To be more compliant, I should call the introspect endpoint to validate an opaque token, then swap the access token with an identification token to extract the username. But this will create a strong coupling with the authentication server and create an extra HTTP call for each API call (unless we add a cache or something).

from readflow.

mpldr avatar mpldr commented on May 18, 2024

I got this token by clicking "Copy Value", which apparently truncated it… What the hell? You're correct. The full token got sent.

The frontend simply sends the access_token to the backend. The backend is expecting a JWT access_token.

Yes, and per OIDC spec. The access_token isn't the one supposed to hold the username. That's the ID_Token (see example from OIDC Spec). And falling back to the token issuer as the username doesn't really make sense either… shouldn't it be sub?

from readflow.

ncarlier avatar ncarlier commented on May 18, 2024

Last commit improve OIDC support. Username is fetched from multiple locations (JWT or introspection or User Info endpoint).

from readflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.