Getting authorization data in geoserver - javascript

i use leaflet, geoserver and js. And also using tomcat
I have more than 400 users and each has its own role, adding more than 400 users to geoserver and configuring them individually is too long.
The user is currently logged in like this:
The question is, if there is any way to get the data of an authorized user and apply roles and filters to it?
I will also say that the users are in the postgres database

Adding an authentication using a JDBC database to GeoServer is a very similar process to adding an LDAP provider. While logged in as admin go to the User, Groups and Roles page from the security menu and choose Add new from the User Group Services menu. Then select the JDBC option, you can then give this provider a new name.
Then you should select the relevant JDBC driver for your database (you may need to add the jar containing that driver to the GeoServer WEB-INF/lib folder). You then need to add the connection URL for your database (e.g. jdbc:postgresql://localhost:5432/ian). It is probably a good idea to make a quick test using a known user password combination in the boxes below. Assuming that works click save to make the change. If you don’t already have any tables with users in then check the create database tables box (don’t worry about the DDL files). Then press save, and go back into the service by clicking on it’s name in the table.
You can then add new roles to the service. Now, you need to create a new Basic username/Password authentication provider. You will now need to scroll down to the Authentication providers panel and move the new provider across to the right hand list. You then need to click on the new provider and set the User Group Service to point to the JDBC one you just created.
There are many more instructions and tutorials in the GeoServer manual.

Related

Pull data from CRM online using Web API

I've created a webpage that will be used as a survey for end users to submit a review of how the helpdesk technician did with resolving a ticket. I've built the webpage using HTML, CSS, JS, and PHP. The page currently needs to pull 2 things from Dynamics 365: Users name and the company. I currently pass the ticket # via the URL which I plan to use as the value in a lookup (somehow).
I think that I need to use the Dynamics API somehow to get access to pull data from the form but I am not sure how to go about that. I found this post online https://functionalthoughts.com/dynamics-365-web-api-retrieve-data-javascript/
which I think is only for web resources created inside of CRM.
Here is an image of what I currently have:
Image
and the value that I have passed via URL Image2
The end goal would be to pull the value of the name and company fields in Dynamics 365 Online.
Without full context of your application, I can only give you high level pointers.
Before anything,
You need to authenticate to Dataverse (the engine that is hosting the data your after). That means you need a an identity + JWT Token to auth.
This is the more complicated part, depending on how your managing access to your site and if your intending to allow dataverse to manage data access security.
To do that, in php, your going to want to start here: https://learn.microsoft.com/en-us/azure/active-directory/develop/reference-v2-libraries#web-application and read up the Python path for MSAL.
Once you have that you will either use a S2S app ( ConfidentialClient app ), or user identity auth ( publicclient app. )
For explanation sake, I am going to assume that you created a Confidential app to work with. In Dataverse this type of login identity is called an "Application User"
Now you need add the application user to Dataverse and grant it permission to read the data you want. You should work with the admin of the dataverse instance to get that setup. if your trying to solo it :) there is a good blog on how to do this here: https://powermaverick.dev/2020/08/10/create-application-user-in-dataflex-pro-cds/ Dont forget to grant your user a security role that can access the data your after.
Next,
You said you want to query by Ticket ID, again assuming that ticket id is in dataverse, you need to create an alternate key for the field that contains the ticket to be able to query on it.
you can find info on how to do that here: https://learn.microsoft.com/en-us/powerapps/developer/data-platform/define-alternate-keys-entity
Ok, now that you have a user to work with and can create a token, and you have an alt key on the column your trying to query on, you just need to form the query to dataverse.
General info on how to form and call queries in dataverse can be found here https://learn.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-data-web-api a specific example of retrieving via alt key can be found here: https://learn.microsoft.com/en-us/powerapps/developer/data-platform/webapi/retrieve-entity-using-web-api#retrieve-using-an-alternate-key
Now that you have all the setup done, and once you have formed your query, you will need to generate the token and add it to the authorization header of the request and send over.
That should get you data back.

Javascript creating hubs?

I have an express server setup that is handling all of my routing and session stuff. I want the system to work so that when a user is logged in they are able to connect to a "hub" like entity that is uniquely based on the location of the "hub". I thought about working it like each of the "hubs" is a collection in a database, but the way it works is that a user connects to the "hub" and then disconnects from it when they are done but can connect to different "hubs" based on a location. How should I go about creating a unique group of "hub" like things that all act as objects with storable data?
Instead of connecting to a "hub", why not just present them with different information from a database based on their location. The user will never really connect to anything other than your single backend. Unless, ofcourse, you set up different servers all over the world (known as a CDN, and probably a bit too much effort).
If you're using express, you could use something like mongodb for data storage.
With mongodb you get the mongoose npm package. With that, you can create Schemas. You could have different Schemas as "hubs" and load the correct ones based on location data. That would let the user see different information for different locations.

Firebase one to one chat implementation for web

I implemented friendly chat. But that is group chat. I am new to firebase. Need docs for creating one to one web chat. How to get list of user accounts and selecting single user to send message? Please help me
If the users communicating have user IDs uid_1 and uid_2.
The database structure should be:
contacts
--uid1
--uid2
--uid3
-- so on (1)
--uid2
--uid1
--uid4
-- so on (2)
messages
--uid1
--uid2
-- Push messages here.(3)
--uid2
--uid3
-- Push messages here also.(4)
Adding Contacts
If USER 1 knows USER 2 you can add USER 2 in location (1) and add USER 1 in location (2). Since you are implementing with user IDs the USERS will be able to send messages if they know the other USER's uid. You can send Chat Invites to exchange uids.
Adding Messages
If USER 1 or USER 2 sends a message add at locations (3) and (4). This implementation will make sure that even if USER 1 deletes a conversation with USER 2, USER 2 will still have a copy and thus ensuring privacy.
These are the key elements to make a basic one-on-one Firebase Chat App.
NOTE: User IDs are provided by Firebase on successful authentication.
Maybe try breaking your problem into individual milestones and learn how Firebase works as you need help in each milestone.
According to what you have written, you have to:
Authenticate Users (https://firebase.google.com/docs/auth/)
Save those user profiles onto the Real-Time Firebase Database in the following data structure (https://firebase.google.com/docs/database/)
List those users in a List / RecycleView (learnhowtoprogram.com/android/data-persistence/firebase-recycleradapter)
Manage the conversation through listeners in the adapter that reference child nodes which serve as rooms between 2 people.
Think about how to make your structure as efficient as possible such as not saving conversations twice under each user but rather saving a reference to a separate 'conversations' node.
I recently implemented this in my location-based app (Occupapp) if you want a live example. You will have to register, add a service and log in from another device and select that service to chat to the owner.

Using MongoDB to separate different user data

I'm already familiar that MongoDB is based on documents that are in JSON format. I'm creating my first web app using the MEAN stack, where users can register and then be able to sign in to a back-end dashboard where they can implement products/profile information etc. How would I set that up to be stored on MongoDB? would each user be stored as a document? And as far as security reasons, how can I go about not allowing a GET request to be able to get a different users information?
Currently, I just have a collection of users, and a collection of products (with the unique id number for each user), etc. to me that doesn't seem the proper way to store data.
If anyone can help me on how to setup the database for Mongo that would be fantastic! Thanks in advance!
would each user be stored as a document?
Yes, each user is an object, thus it's stored as a separate document.
how can I go about not allowing a GET request to be able to get a different users information?
This has nothing to do with Mongo or any other data storage mechanism. You'll need to work on a Web service layer which exposes your data filtering requests to authorize them based on user role, claims or any authorization approach you might find useful in your scenario.
Maybe you should look at implementing OAuth2. There's a package that integrates with Express to implement your own OAuth2 authorization server: node-oauth2-server.
Currently, I just have a collection of users, and a collection of
products (with the unique id number for each user), etc. to me that
doesn't seem the proper way to store data.
You are on the right way actually. Now when you show products page for users you need to retrieve only documents that belong to that single user that is currently authenticated, this implies that you have authentication set up, and products have a userId field.
This is how most application work. If you want to read about other ways of solving this then read about multi-tenancy.

How to access multiple database dynamically using Entity framework 6.1(Power Tool Beta 4) with ASP.NET web api

I've created a project using Asp.net Mvc 4 => Web api...
I have integrated Angularjs in it. and so I'm using single page app.
I'm also using entity framework 6.1.
For Database connectivity, I'm using Entity framework Power tool beta 4 by which I target particular DB and generate DBcontext.
Now scenario is:
There is one other application by which end user can register himself. When he does it, new Database is generated into Database server with "ProjectName+ClientName" name eg. MISSteve,MISJohn...
This new user entry goes into MISDBManager Database which is already there in Database server with new connectionstring and new user.
So, This MISDBManager has clientName and relevant connectionString.
So overall. In Database, One MISDBManager which has different registered users with DB Connection strings.
eg,
(ClientName) - (ConnectionString)
BV - data source=pdev-3\xyz;initial catalog=MISBv;integrated security=true
Steve - data source=pdev-3\xyz;initial catalog=MISSteve;integrated security=true
Now My problem and question is,
When I run my application, logging page comes. user enters his credentials. Now With Power Tool Beta 4, through reverse engineering, I have already generated MISDBManagerDBCOntext against which I check whether credential is valid or not. Till here everything works perfectly fine.
But what I want is, If username & password are valid, I want to connect that valid user to his relevant DB.
As I have stated I'm using EF 6.1, PowerTool Beta 4 and with Reverse Engineering I can only target fixed client. Which is not valid for my Project.
I want to connect valid client to his one DB (generated & stored with different tables into Database server).
with static approach, I can target one client. But when it comes to dynamic approach I dont't know how to do it.
Means, As shown here if BV(ClientName) gets logged in, i can redirect him to Dashboard because I have generated his fixed MISBvDBContext.
But If other user gets logged I can do it.
If i'm having thousand users I can't generate thousand DBcontext. so dynamic approach is needed to connect client to his Database.
Please help me to get this things done. Please let me know if other way is there to connect client to his DB.
Help would be greatly appreciated.

Categories