Using Firebase for generic app distribution - firebase

I'm developing a mobile application which I would like to distribute globally. The app is targeted for managers who want their employees to update data as they are on-the-go, while the manager has a web dashboard that collects and dices the data.
The architecture I would like to implement, is that the manager logs in to the product's website, creates an account, and gets a code. Employees are then asked to download the app, and enter that code upon initial setup.
My question is about the back-end implementation of the setup - I would like for each new customer to have their own firebase instance, which is automatically set up and registered when the account is created.
It seems like the API does not support creating new accounts or new repositories/instances.
Is there a way to create an account/instance using a script? If not, would one instance be able to hold potentially a very large number of tables, each table being a root for a specific customer and their data?
Thanks!

Related

Firebase - How to handle firestore & API changes in previous app versions

I am using Firebase in an app which we deployed a couple of months ago. Of course, a few database changes happened and a lot of new triggers were created, which we now want to deploy to production together with a new app version.
The question is how do we force the previous app version to work with the new triggers and database structure without forcing our users to update the old app? Does anyone have any experience or suggestions in implementing this smoothly?
Some examples of what did change:
A counter to keep track of like counts was set in the app code in the previous version. This now has been moved to a cloud function.
A collection named '/users' is now split in two collections '/users' and '/_users', with '/users' containing all data accessible for all users and '/_users' containing all data only accessible for admins. Also a trigger is built to keep corresponding fields synchronized (fe. the field firstName occurs in '/users' and '/_users') So when a new user is created in the previous app version, the document will contain too many fields, because some belong to the '/_users' collection now. How can this be handled?
I've found out that with remote config we'll be able to force the users to update the app, but still that ain't the way to go for us. The first scenario seems easy to counter by just recalculating the count in the trigger. The second seems a little more complex.

session vs profile to store userID in an extremely simple vb.netapp

I am building an extremely simple VB.net web application that uses Visual Studio's forms authentication. As part of this- I am trying to capture the userID upon login and use it while the user is in the app (to dynamically display information via dataset/gridview that is associated with that userID) so I don't have to give them their userID and prompt them for it constantly.
The app is very simple and uses a local DB to do all the authentication (Users, User_Activation, Roles)
This app will have 9-10 users that will be consistent over the years(logging in 10-15 times a year), and 40-50 rotating users that log in once or twice and do not return past that year.
The profiles and authentication/sessions do not need to handle tons of users and authentication requests.
I also want to avoid cookies because I want to keep everything as simple, and centralized to the application as possible.
I have explored building a GetUserID function that queries the database based on the userName every time a user takes an action (button click, page load) that requires the userID. But I am having trouble with the SQL and it seems bulky.
I have also looked into sessions- but they seem unreliable and difficult to manage.(How do i keep each session separate as users login?)
I am now looking at Profiles
https://msdn.microsoft.com/en-us/library/2y3fs9xs.aspx
https://msdn.microsoft.com/en-us/library/system.web.profile.sqlprofileprovider.aspx
I think I can just use the default instance of the SqlProfileProvider and point it to my database I already have built?
I am very new to programming and am not sure how complex the configuration would be for the Profiles, so any guidance or advice would be greatly appreciated!
I can post any code snippets needed, or upload the app to github or something if that helps at all.
Thanks!

How should I model my data in Firebase?

I am currently developing (my first ever) iOS app using firebase and testing with a small group of users and everything is going fine (because I am hard-coding the org code into the ref builder). The app is structured around having autonomous organizations with its own users hidden from other organizations. The problem that I am running into is how I structure my model so that it is possible to access and it is efficient when it starts to add new organizations and users.
specific problem:
Org names are dynamically created, so my login pattern needs to be able authenticate the user in Firebase, then retrieve the user's data stored in the database under their specific org code. I can't figure out how to save the org code for login each time the user opens the app so they don't need to type it in. Technically I could pull down the whole the database to find it but that's the worst possible solution. Would I maybe need to use Core Data?
-_admin
-org1
-name
-availble_licenses
-used_licenses
-org2
-org3
...
-org1
-users
-$uid
-name
-uid
-email
-$uid
-$uid
...
-org2
...
My answer is based on this assumption
I can't figure out how to save the org code for login each time the user opens the app so they don't need to type it in.
For this, you don't need Core data but UserDefaults. Core data it's for a huge set of data. On the contrary, UserDefaults, it's useful to store tiny data. It's like user preferences :
The UserDefaults class provides a programmatic interface for interacting with the defaults system. The defaults system allows an app to customize its behavior to match a user’s preferences.
So you can use it to store the org code for a specific user.
Here is a tutorial on how to use UserDefaults : UserDefaults

User management in multi-saas with shared auth service

I have a saas platform I'm building and I'm currently struggling with how to model my auth flow. The system is going to be multiple multi-tenant applications but I would like to unify user authorization & authentication. Basically, each US State will have its own web app/resource server/database and every county in that state will be a separate tenant. I cannot combine all states into one application, so that is not an option.
I would like to throw all users and their information/password into one database connected to my auth service. But each county (tenant) admin within each state (web app) needs to be able to add & manager their users and their roles. So the auth service needs to be aware of all the different tenants across each application. I also need to be able to link items created in each database to the user that created it. If I create object "X" and another user in my county views that item, they can see "Kovaci" created this.
I also do NOT want SSO between states but if possible I would like users to be a part of multiple tenants within one app (not a requirement though). Native iOS/Mobile apps are another client I need to support with this flow.
I used this bitoftech article to base off of: http://bitoftech.net/2014/10/27/json-web-token-asp-net-web-api-2-jwt-owin-authorization-server/comment-page-1/#comments
And here is my paint quick mockup: multi saas design
My question is just generally how do I design this auth part? Can I store all users in one auth db like my goal? If so, how do tenant admins manage them and how do I link tables in my separate app db's to the users' current info in the auth db?

ASP.NET Membership on .NET 4.0 Multi-Tenant app. Default or Custom?

This is my first attempt, trying to integrate Membership on an existing shop already in production.
I'm not quite sure, based on my scenario, if I should use the build-in aspnet-providers or custom implementations of them in order to integrate membership.
Here's a few details:
I have a multi-tenant, single database, single schema web app based on subdomain.
The app is already in production and I will later want to link newly registered users with existing anonymous orders by email.
The development will continue after the membership integration, new features will be added, meaning new columns and linked tables for the users table.
This answer got my thinking of using the membership deafult Profile in order to extend the users table created by the aspnet providers, since I don't have users yet. Though its not clear to me how I would link Users with Orders and other tables/entities that might later be added when the app is going to be extended.
Maybe I could define my entities related to users as user-defined profile properties but they would not have associations on my database.
Another overhead I'm thinking of is how would I associate the users with the different tenants of the app. I would want users to be able to regiter in different tenants/subdomains with the same email.
How would you implement membership in this scenario?
This question is an aggregate of a few questions. I will try to answer them to he best of my knowledge
In case of managing users, i would like to suggest that you consider the following approach
Pre-define a list of basic user profile metadata that you will need in the application
Create an extensible approach like having custom fields for the user profile so that it can accommodate any data that may be required to capture in future
You should also be planning for a self-registration system in the application that will allow your user's to register themselves like the anonymuous ones that use the system with an email
Regarding associating the business entities, you will require to associate the entities with the tenant and not with the user. the level of application will be from the tenant and then it will flow down to the users.
Additionally, you should not have the user accessible business entities, when they are maintained in a form of package or so, it will be very easy to manage and use.
Share your thoughts on these approaches.
- Create a tenant identifier column [property] for each profile that identifies the base tenant to which the user belongs to
- create a table that manages the list of other tenant's that the user may be gaining access to at a later part

Resources