Skip to content

Support for multiple apps/project (duplicate users) #114

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

Closed
gbkwiatt opened this issue Jan 7, 2022 · 6 comments
Closed

Support for multiple apps/project (duplicate users) #114

gbkwiatt opened this issue Jan 7, 2022 · 6 comments
Labels
feature requests 💡 For issues that are possible feature requests good first issue ✅ Good for newcomers hacktoberfest

Comments

@gbkwiatt
Copy link

gbkwiatt commented Jan 7, 2022

I was just creating my own OAuth2 server base on this repo.
Main advantage in my head was, that I can use this server for multiple projects, but with that it means usernames could be duplicates, e.g. same users for different apps.

my idea was, to store users, against clientId however on getUser we don't have clientId to fetch it by.

Is there something I am missing ? is there better way to do it currently?

Or is it even a good idea to do it at all ?

@jankapunkt
Copy link
Member

This is up to your implementation, this package is not scoped for user management. In my projects we have an authenticated / authorized route (authorization code grant workflow) that returns the user's identity and there we fetch user by id.

Maybe you add some code snipped on how you currently retrieve your user and maybe we can make a generic solution as example for the documentation out of it.

@gbkwiatt
Copy link
Author

gbkwiatt commented Jan 7, 2022

All I got for fetching the user is username and password, assuming username usually is email, it won't allow multiple apps/project for same users

So I want to fetch user by username + clientId pair and make that pair unique in the table

I think it will be sufficient if you add client argument to password grant.
e.g in password-grant-type.js

return Promise.bind(this)
    .then(function() {
      return this.getUser(request, client);
    })
    .then(function(user) {
      return this.saveToken(user, client, scope);
    });

and then
PasswordGrantType.prototype.getUser = function(request, client) {
and
return promisify(this.model.getUser, 2).call(this.model, request.body.username, request.body.password, client)
This would allow to fetch user for given client.

This is just my idea, not sure if that solution is against some rules of OAuth2 ?

@jankapunkt jankapunkt added the question ❓ Information is being requested label Jan 13, 2022
@jorenvandeweyer
Copy link
Member

I think this would be a good improvement to provide the client in the getUser function. We don't break any compatibility and provide a possibility to implement a multi tenant oAuth2 solution.

getUser (username: string, password: string, client?: Client) {

}

@jorenvandeweyer jorenvandeweyer added good first issue ✅ Good for newcomers feature requests 💡 For issues that are possible feature requests and removed question ❓ Information is being requested labels Aug 26, 2023
@jankapunkt
Copy link
Member

@jorenvandeweyer I agree but let's add this to release 5.0.0

@jankapunkt jankapunkt added this to the v5 milestone Aug 26, 2023
@jankapunkt jankapunkt removed this from the v5 milestone Oct 1, 2023
@jorenvandeweyer
Copy link
Member

Implemented by #256

@jankapunkt Do you think you can create a new RC?

@jankapunkt
Copy link
Member

Of course, coming in today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature requests 💡 For issues that are possible feature requests good first issue ✅ Good for newcomers hacktoberfest
Projects
None yet
Development

No branches or pull requests

3 participants