lowcoder-org / lowcoder

🔥 🔥 🔥 The Open Source Retool, Tooljet and Appsmith Alternative
https://www.lowcoder.cloud/
GNU Affero General Public License v3.0
823 stars 175 forks source link

[Bug]: Generic OAuth login Failed #1112

Closed tiodot closed 1 month ago

tiodot commented 1 month ago

Is there an existing issue for this?

Current Behavior

I config a salesforce OAuth with the Generic auth type. I login with salesforce account successfully at the first time, but failed then.

While I try to login, there will occur an error: image

And the server error log is:

 o.l.api.framework.exception.GlobalExceptionHandler#lambda$doLog$8:155  POST /api/auth/tp/login [nioEventLoopGroup-3-9]:  
java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because the return value of "org.lowcoder.domain.user.model.Connection.getRawId()" is null
        at org.lowcoder.api.authentication.service.AuthenticationApiServiceImpl.lambda$getAuthConnection$18(AuthenticationApiServiceImpl.java:240)
        Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.MonoFlatMap] :
        reactor.core.publisher.Mono.flatMap
        org.lowcoder.api.authentication.service.AuthenticationApiServiceImpl.updateOrCreateUser(AuthenticationApiServiceImpl.java:158)
Error has been observed at the following site(s):

Expected Behavior

Can use the salesforce account to login lowcode successfully.

Steps to reproduce

  1. self-host the lowcoder;
  2. config the user authentication with oAuth
  3. login with the salesforce account, and login in other device or just logout then login again.

Environment

self-host lowcoder 2.4.4

Additional Information

Data in mongodb seems missing the rawId while using the OAuth:

// normal
connections: [
      {
        authId: 'EMAIL',
        source: 'EMAIL',
        rawId: 'test@test.com',
        name: 'test@test.com',
        email: 'test@test.com',
        orgIds: [],
      }
    ]

// exception
connections: [
      {
        authId: 'xxx',
        source: 'GENERIC',
        name: 'xx',
        email: '-@salesforce.com',
        avatar: '-',
        orgIds: [ '-' ],
        authConnectionAuthToken: {
        },
        rawUserInfo: {},
       tokens: [],
  }]
tiodot commented 1 month ago

Ops, I config the wrong mapping field of uid. Just use the user_id replace openid is ok now.