authgear / authgear-server

Open source alternative to Auth0 / Firebase Auth
https://www.authgear.com
Apache License 2.0
72 stars 29 forks source link

Make "node id" in GraphQL and "id" identical #1970

Open fungc-io opened 2 years ago

fungc-io commented 2 years ago

Problem

When communicating with Authgear, developers will see two versions of "id" in different scenario.

  1. In the portal, webhook, userInfo from SDK, and the sub of JWT, users are identified by a uuid
  2. In admin API, the users are referred by a node_id which is a base64URLencode("User:"+uuid)

Although a similar design is practiced by GitHub API, this is not natural to a developer, and developers may found it quite strange.

Proposed Changes

chpapa commented 1 year ago

Actually if all entities in Authgear are using uuid as ID, what if we make it simpler by:

  1. Just replace UUID with node ID in graphQL
  2. Migrated users DB will have user id as uuid as well, and old user id, if any, shall be put in custom attributes
louischan-oursky commented 1 year ago

All IDs are UUID, including user ID. But UUID is not enough for GraphQL because GraphQL define a node(id: ID) field that every GraphQL must implement. That means the ID must tell the type of the node and the ID of the node.

To solve this problem, I want to adapt a similar ID format used by Stripe. The IDs of Stripe looks like prod_NwKkamouCWQvls which is an ID of a particular Stripe Product. This format encodes the type and also URL safe. Of course this change only applies to new projects.

chpapa commented 1 year ago

To solve this problem, I want to adapt a similar ID format used by Stripe. The IDs of Stripe looks like prod_NwKkamouCWQvls which is an ID of a particular Stripe Product. This format encodes the type and also URL safe. Of course this change only applies to new projects.

So it's like user_[UUID]?

Ya that seems good enough and avoids the trouble/performance of overhead for us to build a global object index