You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Is there a way to change the default userInfo table? I basically want to use uuid instead of int as ids.
Its sort of a security bug that its user guessable
Describe the solution you'd like
Not use userInfo object and just extend it, but that would mean rewriting a custom auth .
Maybe I'm missing something, but #641 just added support for using UUIDs in the protocol specification. There is currently no change to the userInfo table or the auth module. changes
Yeah I checked that, It just adds the option to do use uuid field, and not change it. My main thing was to be able to override id field coz you see I could use a string to represent the uuid, but I can't change it id field is set by default. If this is something you wanted to support and someone else is not working on it, I can pick this up.
Proposed solution if id is provided in the field use that instead of generating a default one.
Proposed solution if id is provided in the field use that instead of generating a default one.
This would be a nice feature, but I don't think this is enough, since the serverpod generate does not run in modules when you run it in your project. I think with the current logic something like this is only possible by forking the auth module, but I might be wrong about that.
Using UUIDs as ids in userInfo should be equivalent to adding additional columns to tables / classes generated in modules. To support this, quite some refactoring should be required, but maybe @vlidholt has an idea.
ok so m not talking about specifically about userInfo table coz thats auto generated, but in general for any other table. Also I just started experimenting with it like a couple of days ago found It interesting so I thought why not give it a go. If you think I can tackle that id thing like a more general thing ill pick this up and try to make a PR.
I have a very simple fix for it tbh, what if I make the TableRow class generic over T and use that instead of int, so not a lot of code change would be required and it would be pretty flexible too.
what if I make the TableRow class generic over T and use that instead of int, so not a lot of code change would be required and it would be pretty flexible too.
It's generally a good idea to use an int as the idea internally in the server for many reasons (this is what most sites, including big ones do). What is shown towards the client may be another issue. Having a UUID attached to a user can have certain uses, but another solution can also be to use a method that converts the id to a unique string using some encryption algorithm. The string can then be reverted back to an id if you have the key. There are libraries for this, just cannot remember the name from the top of my head.
so what I usually see int stored in the database as storage/ memory saving technique and can have performance difference too at some level, but I believe the current design is too opinionated. The default can be int but user should have the flexibility to use anything if required.
Activity
yahu1031 commentedon Feb 12, 2023
The enhancement was already merged, need to make a release.
fischerscode commentedon Feb 12, 2023
Maybe I'm missing something, but #641 just added support for using UUIDs in the protocol specification. There is currently no change to the
userInfotable or the auth module. changesramyak-mehra commentedon Feb 12, 2023
Yeah I checked that, It just adds the option to do use uuid field, and not change it. My main thing was to be able to override id field coz you see I could use a string to represent the uuid, but I can't change it id field is set by default. If this is something you wanted to support and someone else is not working on it, I can pick this up.
Proposed solution if id is provided in the field use that instead of generating a default one.
fischerscode commentedon Feb 12, 2023
I THINK nobody is working on this.
This would be a nice feature, but I don't think this is enough, since the
serverpod generatedoes not run in modules when you run it in your project. I think with the current logic something like this is only possible by forking the auth module, but I might be wrong about that.Using UUIDs as ids in
userInfoshould be equivalent to adding additional columns to tables / classes generated in modules. To support this, quite some refactoring should be required, but maybe @vlidholt has an idea.ramyak-mehra commentedon Feb 12, 2023
ok so m not talking about specifically about userInfo table coz thats auto generated, but in general for any other table. Also I just started experimenting with it like a couple of days ago found It interesting so I thought why not give it a go. If you think I can tackle that id thing like a more general thing ill pick this up and try to make a PR.
ramyak-mehra commentedon Feb 12, 2023
any docs about the architecture in general would be kindaa helpful
fischerscode commentedon Feb 12, 2023
I think this would be nice to have, but @vlidholt would have to decide whether this is something he wants to have. (I'm just a contributor...)
I think there are none, but feel free to @mention me when you have a question, I think, I have a good overview of the generator part.
I think the most relevant parts would be:
serverpod/packages/serverpod/lib/src/database/table.dart
Lines 10 to 12 in 046b955
serverpod/tools/serverpod_cli/bin/generator/class_analyzer.dart
Lines 255 to 267 in 046b955
serverpod/tools/serverpod_cli/bin/generator/class_generator_dart.dart
Lines 57 to 58 in 046b955
serverpod/tools/serverpod_cli/bin/generator/class_generator_dart.dart
Lines 82 to 93 in 046b955
serverpod/tools/serverpod_cli/bin/generator/class_generator_dart.dart
Lines 99 to 117 in 046b955
findById:serverpod/tools/serverpod_cli/bin/generator/class_generator_dart.dart
Lines 428 to 443 in 046b955
(I'm missing parts for sure)
ramyak-mehra commentedon Feb 12, 2023
I think it should be pretty straight forward, Hey @vlidholt, if you give a green light I can work on this.
ramyak-mehra commentedon Feb 12, 2023
I have a very simple fix for it tbh, what if I make the TableRow class generic over T and use that instead of int, so not a lot of code change would be required and it would be pretty flexible too.
fischerscode commentedon Feb 12, 2023
In here?
serverpod/packages/serverpod/lib/src/database/table.dart
Lines 10 to 12 in 046b955
That's what I've done, too.
Use this method to get the type reference later in the generator.
serverpod/tools/serverpod_cli/bin/generator/types.dart
Lines 94 to 99 in 046b955
ramyak-mehra commentedon Feb 12, 2023
let me try to come up with a poc and then well see
vlidholt commentedon Feb 13, 2023
It's generally a good idea to use an int as the idea internally in the server for many reasons (this is what most sites, including big ones do). What is shown towards the client may be another issue. Having a UUID attached to a user can have certain uses, but another solution can also be to use a method that converts the id to a unique string using some encryption algorithm. The string can then be reverted back to an id if you have the key. There are libraries for this, just cannot remember the name from the top of my head.
ramyak-mehra commentedon Feb 13, 2023
so what I usually see int stored in the database as storage/ memory saving technique and can have performance difference too at some level, but I believe the current design is too opinionated. The default can be int but user should have the flexibility to use anything if required.
momadvisor commentedon Jun 18, 2024
I deeply agree with you, @ramyak-mehra.
SandPod commentedon Dec 17, 2024
If I understand the conversation here correctly, the core of this issue is that user ids should not be guessable.
Therefore, I'll close this as a duplicate of: #554
If that issue is resolved, then this issue should also be fixed.