[Feature request] Disable new user signups
When a new user types their email address in the signin form, it shows the new signup form. How can I disable this? I just want the users who I have already created from firebase console to access my app.
Hey @arhmnsh, that is currently not supported. It is not a common feature. In fact, it is hard to block that for OAuth sign in as you can't tell if the account is already created or not before launching the sign in to that provider. I am assuming you are using password sign-in in your case.
@bojeil-google but it's implemented in FirebaseUI for Android and will be shipped in version 1.2.0. Here's the link: https://github.com/firebase/FirebaseUI-Android/issues/530 FirebaseUI for Android and iOS have feature parity so I assume it'll show in iOS as well. It would be useful for users who have mobile app for their web app.
FirebaseUI 1.2.0 is already released, and mentioned functionality is present as per milestone: https://github.com/firebase/FirebaseUI-Android/milestone/13?closed=1 and issue: https://github.com/firebase/FirebaseUI-Android/issues/530
@krisdev-pl hi! Thanks for the info. but this issue is to restrict new user signups for firebaseui-web, not for mobile apps :)
I'm trying to use firebaseui-web on a project atm and we're using EmailPassword Auth only with AccountChooser.com disabled. We need the ability to hide or disable users creating accounts.
Our requirements are that either we need to send them a special link for them to create an account or we need to manually add their account before they login.
Currently there does not seem to be a simple way to disable account creation in firebaseui-web w/o forking the project. Please add an option to enable/disable account creation when using EmailPassword Auth.
Would really love to see an option to disable new user sign-ups. I built a tool for internal use only, and there's no reason for anyone to ever sign-up. It's just a small pool of users who need admin access that I'd like to manage within the Firebase console.
Is this issue taken care in FirebaseUI version 2.3.0 ?
I am trying to disable sign up too because this make request.auth != null unusable for firestore, because everyone can just signing up an account and have the read access to the database.
one more thing is someone can spam a fake account on our authentication and how to prevent that ?
@rained23 your question seems better suited for stackoverflow. You can't disable sign up by using Firebase rules as it will also block users that you sign up on your end too and who later sign in.
FirebaseUI has plans to disable sign up but it may lack teeth as this seems like a feature better enforced on the Firebase Auth backend first. You are welcome to file an official request for it: https://firebase.google.com/support/ For now, we plan to return the isNewUser boolean on sign in via FirebaseUI. That will tell you if a user is new or existing. You could build on that but only enforce it on the client.
When you refer to fake account, do you mean fake emails? If so, you should send an email verification after FirebaseUI sign in and then monitor your users and delete those who do not verify after a while. Firebase Admin SDK provides tools to look up all your users and delete them if you want.
Possibly this could be done with Custom claims: https://firebase.google.com/docs/auth/admin/custom-claims
You would have a server (you could use Cloud Functions with a user().onCreate() trigger or an HTTP trigger if you want to do this in a sync'ed way) that checks if the user is allowed to signup and add a custom claim to the user. For instance something such as allowed = true or false. On the client you could wait for the server to set this custom claim for the user, refresh the user and check if it is true or false and display the appropriate UI.
You can use the custom claims in the security rules to allow only users with the allowed custom claim to read data.
Good suggestion @nicolasgarnier. I like that one.
My use case: we want signup to be a back office process after contracts are signed. We don’t want sign up to be easy.
Due to this issue we are going to implement our UI in our own way via using the REST api.
I think its a very useful feature for firebaseui-web!
For now, I'm using the workaround for auto disable new users using cloud functions.
const admin = require("firebase-admin");
exports.blockSignup = functions.auth.user().onCreate(event => {
return admin.auth().updateUser(event.data.uid, { disabled: true })
.then(userRecord => console.log("Auto blocked user", userRecord.toJSON()))
.catch(error => console.log("Error auto blocking:", error));
});
Remembering that this function is also fired when you create users using the firebase web console. So you have to create, await the function, then enable the user.
Since this is still open: I also require google provider login but only for users who already exist. Block any attempts to login with a new google account that's not yet in my firebase user list.
I wanted to use firebase auth so I can reduce the development for authentication, look at the situation just to disable sign up require a lot of work, I moved to other provider which doesnt require me to do any code regarding authentication which work mostly for normal cases. I think a simple function like this which have many occurrence in most use case should be available as Firebase known to try to remove most of backend thing.
On Sat, Jan 27, 2018 at 10:57 AM, Luca Ban [email protected] wrote:
Since this is still open: I also require google provider login but only for users who already exist. Block any attempts to login with a new google account that's not yet in my firebase user list.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/firebase/firebaseui-web/issues/99#issuecomment-360954703, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3YLYBDcAIJtnEt_rhj3zI6sKe7j8-9ks5tOpCjgaJpZM4Lso6u .
Hey @rained23, we should definitely support this use case and it is on our list.
I still think that @nicolasgarnier's solution is actually very feasible and doesn't require much work. The only additional work you are doing here is setting the custom attribute when creating the account (to differentiate users your admins created) and adding a check in your Firebase security rules or ID token verification for that attribute.
Anyway, you can also submit an official request for this feature via Firebase support.
@nicolasgarnier
For instance something such as
allowed = true or false. On the client you could wait for the server to set this custom claim for the user, refresh the user and check if it is true or false and display the appropriate UI.
Do you mean if you retrieve the user from the server and then on the client side check for the value allowed and then display the UI according to that?
Since you have to check for the value on the browser side, there no stopping people from editing your front-end code and making allowed true just before it gets checked.
Am I correct and could this pose a security issue? Or is there a safe way where the users on the front end can't mess with the values that came from the server?
If you want to disable sign ups from the client, you would basically use the Admin SDK to create the user and set the custom attribute allowed on that user. Doing this via the Admin SDK ensures that only an admin can create the user.
In your Firebase security rules or if you are using your own server and verifying the ID token on your own, you would only allow users with that custom attribute to access data.
This has to be enforced on the server/security rules. Client side checks are helpful to show the appropriate UI and messaging to the user. They should not be relied upon. This is helpful if a user tries to sign up and the attribute is not there. You could also check isNewUser is true in UserCredential when signing in with the client and show the error message. Even if the user modifies the client, they still won't be able to access the data as your server will enforce that check.
Does anyone have a small code example for this workaround?
If there could be a hook server side on login (even through google provider) I could set up:
If (!allowedUsersEmailArray.contains(user.email)) user.signOut()
I know this is front end code but that's the gist of what I'd want to be able to do server side with the great Firebase.