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

bug: unable to call the user info endpoint when integrating Logto Cloud with rust openidconnect. #6589

Open
1 of 4 tasks
AH-dark opened this issue Sep 17, 2024 · 5 comments
Open
1 of 4 tasks
Labels
bug Something isn't working pending-verification Something is still under investigation

Comments

@AH-dark
Copy link

AH-dark commented Sep 17, 2024

Describe the bug

Based on the response in this GitHub issue, I suspect that the OIDC content provided by Logto may not fully comply with the standard.

When calling the userinfo endpoint with the openidconnect library, a parsing error occurred. This might suggest an issue with how the user information is being returned or formatted, potentially due to a deviation from the expected OpenID Connect standard in the response from Logto.

Expected behavior

This API should return a 200 status code along with JSON content compliant with the OIDC standard.

How to reproduce?

Retrieve user info using Rust’s openidconnect 3.5.0 and Logto Cloud.

Context

  • Logto Cloud
  • Self-hosted, Logto version =
    • Container (Docker image)
    • Raw Node.js
@AH-dark AH-dark added the bug Something isn't working label Sep 17, 2024
@AH-dark AH-dark changed the title bug: when integrating Logto cloud with Rust’s openidconnect library, I encountered an issue. bug: unable to call the user info endpoint when integrating Logto Cloud with openidconnect. Sep 17, 2024
@AH-dark AH-dark changed the title bug: unable to call the user info endpoint when integrating Logto Cloud with openidconnect. bug: unable to call the user info endpoint when integrating Logto Cloud with rust openidconnect. Sep 17, 2024
@wangsijie
Copy link
Contributor

Coud you please provider a sample project to reproduce this issue? Or full error messages of the response, and your OIDC configurations.

@wangsijie wangsijie added the pending-verification Something is still under investigation label Sep 18, 2024
@AH-dark
Copy link
Author

AH-dark commented Sep 20, 2024

Coud you please provider a sample project to reproduce this issue? Or full error messages of the response, and your OIDC configurations.

pub async fn get_user_by_token(&self, token: String) -> Result<(user::Model, CoreUserInfoClaims), Error> {
    let access_token = AccessToken::new(token);
    let user_info_claims: CoreUserInfoClaims = self.client.user_info(access_token, None)?
        .request_async(async_http_client)
        .await?;

    let sub = user_info_claims.subject().as_str();
    let user = self.get_or_create_user(sub).await?;

    Ok((user, user_info_claims))
}

Here is a simple code snippet that demonstrates a straightforward method using the standard CoreClient and CoreUserInfoClaims provided by openidconnect.

My application is quite large, so it’s difficult for me to extract a complete application. You can use any SPA application (I am using React and @logto/react) to log in via the OIDC service provided by Logto Cloud, obtain the Access Token, and pass it to the Rust backend. Then use this Access Token, request the /oidc/me endpoint and returns an erroneous response.

@wangsijie
Copy link
Contributor

I'll take a look soon.

@AH-dark
Copy link
Author

AH-dark commented Sep 24, 2024

It seems that Logto does not omit null values, and the returned updated_at and created_at are unix timestamp milliseconds not seconds, which is not in compliance with the standard.

@wangsijie
Copy link
Contributor

hi @AH-dark, thanks for your detailed information, there are two things to do:

  1. Omit fileds with null value
  2. Change the updated_at unit to seconds.

However, this will cause a breaking change, so let's hold for now, need to discuss with the team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pending-verification Something is still under investigation
Development

No branches or pull requests

2 participants