Working on a project for class specific to the college network.
The idea is that if we can fetch an identifying characteristic of the web session/connection on campus, we can map out and associate the AP with their location coordinates and plot them on a map. More specifically, we're trying to determine which AP the device is connected to.
Basically the user would bring up a webpage on the intranet from a wi-fi enabled device (preferably an iPad or iPod Touch), and either on the page load or through an action event an unique identifier is captured; which we could in turn associate with lat & long coordinates. The idea here is that the unique identifier would be sent and stored into to a DB field (almost like a guestbook submission). Then, externally on a separate public webpage - viewers would be able to see these unique identifiers returned and translated as the most recently visited locations plotted on a map. This would translate to a manual "check-in" tracking service.
Capturing the IP address will not work as they are not static.
BSSID is part of the active connection attributes set and as such is stored inside the client networking component of the OS. You need to query it by calling the appropriate API of your OS (e.g., in Windows it would be WlanQueryInterface). You'll also need to be able to call this API from script, you can find some info about this here: How to call Windows API functions in JScript?
Related
I have been integrating Launch Darkly (LD) into a Remix app recently and have been following the example from LD here. The example was not quite sufficient for my use-case but was very close.
To summarise the implementation: flags are fetched from LD on the server, saved to a new property on the window object and then used (via a React context hook) in the components that need them. On the client, when a user signs in to the app we "identify" them using the client.identify() method, this is where we can send the user's ID and email address, for example, so they can be targeted later with Segments etc. Once they are identified properly, new flags for that user are fetched and merged with the existing flags.
The issue I have is that the identify call is on the client, which means that there is a delay before the user's flags can be truly used resulting in a potential flash of broken UI (e.g. we show a button if the user belongs to a certain segment).
Ideally I'd like to identify on the server side, where we already know the user info, and pass those flags to the client without the problematic "flash".
I can see that both the client and server SDKs have an identify method, but what I'm not sure with the likes of Next.js and Remix is if it going to cause problems if we do. The LD docs state:
Client-side SDKs are configured to operate for one user at a time, identified or anonymous. In these SDKs, the identify feature allows customers to change the user context, such as if a user logs in or changes their user settings. Identifying users will cause LaunchDarkly to index them.
Server-side SDKs operate for multiple users concurrently. Unlike in client-side SDKs, server-side SDKs do not have a notion of "changing the user context" because users are directly passed to client method invocations for actions such as evaluating flag variations.
...because of the isomorphic nature of Next and Remix, it is not clear to me if it is a mistake to identify on the server-side or not..
I'm quite new to React and after doing a Todo web app I've tried creating my first fullstack web app.
The app sends a request upon entering an Email and pressing a button that should send the users mail to a DB and get his IP which would also be stored into the same DB. This would later be used to check if the user had already done something on the site (After entering the email the client-s sent to the next page) and disallow the user to proceed if either the email or IP are already stored in the DB. What would be the best way to both grab the IP upon entering the email and what would be the best approach in regards of storing it into a DB? (Should I even store it there is there a better alternative).
I'm writing my code with Typescriptx and using Express for my backend & postgres for my DB.
TLDR: How to get the clients IP onClick / upon recieveing a request from them and store it in a database to later compare when the user sends the same request again
On the server side, you can get the IP address from the incoming request. That's the right way to do this (but see below: I think you probably don't want to do this).
In express, this is available via req.socket.remoteAddress. If you're behind some kind of reverse proxy like a CDN then this will give you the CDN's IP, not the real user, but all modern proxies will include the original IP in a request header such as X-Forwarded-For to work around this. You can get the IP from there instead, if that's present. You'll need to look at the docs for your specific infrastructure to check the header they use in this case.
That said, it sounds like you're trying to ensure each user can do exactly one thing, so that after sending an email nothing else is allowed. Is that right?
If that's the case, limiting it by IP address isn't a great solution. Two reasons:
Many users share an IP address, e.g. many many mobile users who are behind CGNAT, everybody sharing an office/home, etc etc
At the same time, many users have multiple IP addresses, e.g. offices that use multiple internet connections in parallel for failover or performance, or people taking their computer from their home to a cafe, etc etc.
In both cases, you'll end up blocking or allowing large numbers of users incorrectly. Typically this kind of thing is done with cookies/local storage on the client side instead, which lets you block this individual user's browser. That will work correctly in environments with shared IPs and environments with multiple IPs.
A client-side approach is not 100% secure, since a technical user could easily clear their cookies to avoid this. If you need a hard guarantee though then neither option would work (it's easy to change your IP too: go sit in the coffee shop outside, or use your phone as a hotspot). In that case, you need to tie the user to something they can't as easily change, maybe an email address, credit card, or even legal ID if you're seriously trying to lock this down hard.
I wouldn't bother: for most web app, client-side storage is usually the right choice.
I am trying to receive the user name on a mobile device. I have tried
Plugin.DeviceInfo;
but i get info only about the device. I need to get info about the name and the number that the user has. Any suggestions?
Getting the User name will not work with Plugin.DeviceInfo; Plugin. This plugin is used to access DEVICE INFORMATION, such as OS, Device type...
If you want to get the user name on Xamarin.Forms, you should do it separately on each platform and call the appropriate implementation with the Dependency Service.
HERE is a great blog post which describes fully how to get the user name of a device owner with Xamarin.Forms. I think it is exacltly what you are looking for.
Suppose I have the following tables in my database (which I can redesign at will if I want to):
user: info about users of the system each user has a set of
authorization.
authorization: info about what each authorization means. each
authorization is associated with a number of hosts it applies to.
host: info about hosts involved in the application. each host has a
location.
areas: groups locations together.
location: group hosts together.
I want to design a webservice interface to this database schemas so that
clients of this webservice will be able to ask questions such as:
what are the users of this system?
what authorizations has user X?
in what location is host Y?
what are the hosts located in location Z?
-. .... and so on.
What should the functions/methods of this interface be?
One popular solution is to have:
getuser(id)/getusers() get users, along with the list
of ids of authorizations each user have.
getauth(id)/getauths() get all authorizations along with the
list of ids of hosts they apply to.
gethost(id)/gethosts() get all the hosts. along with the id of
the location of each host.
.....
With this scheme, getting the location of a hosts means doing two calls
to the api:
h = gethost(id),
loc_id = h.location_id;
location = getlocation(loc_id);
What I don't like about this approach is that it forces the client of
the api to do a lot of (asynchronous) calls to the API tracing through
the hierarchy of objects before getting the info he wants.
In your experience is this the best way to do this?
PS. If your solution involves changing the schema, I'm all ears too.
EDIT: In other words, what I want is good middle ground between
Solution 1: Web service has only one method: query(String) which accepts a query in some db query language like SQL.
Solution 2: Web service has one method for every possible query that users might want: getUserWithAuthorization(user_id) getUser(user_id) getLocationOfHost(host_id) getAreasWithLocations(), ... etc. #interfacebloatinghell.
First of all, drop all verbs (getResourceX).
Usually you can design the API in the way that a client MAY do a single call and getting all the information but also get data on a more granular level.
If I assume correctly your set of data in order from largest to smallest subsets is like this:
Areas -> Locations -> Hosts -> Authorizations -> Users
So this can be your resource URI
1 get call to
api/areas
will return all Areas along with all their Locations and for each Location their hosts etc.
If you want information about a particular Area you can do 1 call to
/api/areas/{id}
We have developed an application in Salesforce.com to geocode and display account information (address information) on Google Maps within Salesforce.com. We have around 750k addresses for the initial (one-time) geocoding process (static address data), as we store the lat/lon with the account.
Is their any way to get this geocoded done in one 'batch' as we seem to hit the daily allowance of request per day (3k)?
Thanks for your support and feedback.
If you'd like to use Google to do this and you need to precompute the lat/lon coordinates, you'll need to upgrade to the Google Maps API for Business. The table on that link provides a detailed overview of the limit differences, and I suspect that the terms of use may also be more in line with what you're developing too.
If your goal is to create a Google Map from the addresses, you may also consider just passing the address data instead of the latitude and longitude. Their static maps will work fine as long as you know which locations that you'd like to use on the map, you don't have too many locations in one map and you don't need interactivity. Otherwise, you should use the javascript API and their documentation is very good for that.
If you don't know which locations you'd like to use on the map, you could use the lat/lon coordinates of their zip codes (which are freely available) to create a view port.
If you'd like a static map of the locations (whether or not you precompute the lat/lon), I'd recommend taking a look at the apexgooglestaticmap Github repository. It makes it quite easy to make certain types of static Google maps in APEX and VisualForce. Here's an example from that README:
APEX Controller
String[] homes = new String[]{'Albany, NY','Wellesley, MA','New York, NY','Pittsburgh, PA','01945','Ann Arbor, MI','Chicago, IL'};
GoogleStaticMap.MapPath moves = new GoogleStaticMap.MapPath(homes).color('0x000000ff');
String movesUrl = new GoogleStaticMap().addPath(moves).url;
Visualforce Page
<apex:image value="{!movesUrl}">
Google Maps URL and Image
https://maps.google.com/maps/api/staticmap?sensor=false&size=500x350&markers=label:0%7CAlbany%2C+NY&markers=label:1%7CWellesley%2C+MA&markers=label:2%7CNew+York%2C+NY&markers=label:3%7CPittsburgh%2C+PA&markers=label:4%7C01945&markers=label:5%7CAnn+Arbor%2C+MI&markers=label:6%7CChicago%2C+IL&markers=label:0%7CAlbany%2C+NY&markers=label:1%7CWellesley%2C+MA&markers=label:2%7CNew+York%2C+NY&markers=label:3%7CPittsburgh%2C+PA&markers=label:4%7C01945&markers=label:5%7CAnn+Arbor%2C+MI&markers=label:6%7CChicago%2C+IL&path=weight:5%7Ccolor:0x000000ff%7CAlbany%2C+NY%7CWellesley%2C+MA%7CNew+York%2C+NY%7CPittsburgh%2C+PA%7C01945%7CAnn+Arbor%2C+MI%7CChicago%2C+IL&
There are also many other geocoding APIs available. They each have their own terms of service, so make sure that your application matches the acceptable uses before you build anything with them. I've personally used PCMiler Web Services with success, and Geonames for reverse geocoding (they have a number of other great features too).
Google only allows that max per IP Address. If you were able to maximize the locations you were doing them from, max out at work, home or maybe your local starbucks, you could be able to hit the goal easily. If you have more than 250 employees just assign the 'homework' of going home and geocoding it! Spread the wealth, and the fun, of geocoding!
The other solution is using Google Maps API For Business, which allows you to do a max of 100,000 requests per day. For more information look at: http://code.google.com/apis/maps/documentation/geocoding/ ; for more information specifically on Geoogle Maps API For Business: http://code.google.com/apis/maps/documentation/business/index.html
I use this geocoder, and add my list and use yahoo to get the lat and long.
We have FindNearby installed, so once I get all the addresses geo-coded, I add them back into my excel worksheet in the respective column that has the Record ID. Since we use FindNearby, I have to add a column that is titled Mapping Status, and all cells under this say Located. I used ApexData loader to mass upload into SF. Note, geocoder has a limit of only 1000 records at a single "code" click, but it has no limit of how many lists you can process per day.
I changes some code to use Bing map services instead of google. There limits are based on keys and are much larger. Also when the key hits its max requests, then you can just get a new free key and apply it.