Enable users to access their accounts from a single designated computer

As I develop my WebApp using C# .net, I am looking to implement a feature that allows users to connect from only one specific computer. After the user logs in for the first time, I plan to save their PC details and restrict access if they attempt to log in from a different PC.

My attempted solutions:

1) Saving the IP address upon initial login and verifying it with each subsequent login - however, the issue arises when the IP address changes.

 protected string GetIPAddress()
{
    System.Web.HttpContext context = System.Web.HttpContext.Current; 
    string ipAddress = context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];

    if (!string.IsNullOrEmpty(ipAddress))
    {
        string[] addresses = ipAddress.Split(',');
        if (addresses.Length != 0)
        {
            return addresses[0];
        }
    }

    return context.Request.ServerVariables["REMOTE_ADDR"];
}

2) Storing a unique key in local storage for verification during login - yet, this method is not foolproof as users can clear local storage, opt out of using it, or have unsupported browsers.

localStorage.setItem("key", "123123");

I seek a more effective and secure approach to achieve this. Any suggestions?

Answer №1

While I understand @nvoight's concerns about the unconventional nature of this proposal, there is a potential workaround that could be implemented:

To begin, create a database table on the server side to associate usernames with unique "tokens." When a user logs in for the first time, generate a random token and store it in the database alongside the corresponding username. Additionally, include this token in a cookie within the HTTP response. Subsequently, each login attempt can be verified by comparing the cookie token to the stored token in the database.

Despite this approach showing promise, there are notable drawbacks to consider. For instance, if a user deletes their cookie (similar to removing data from localStorage), they would be unable to log in from any device unless they contact you to delete their record on the server side. Moreover, attempting to log in from a different browser on the same machine may pose challenges. Furthermore, without utilizing HTTPS, cookies sent as plain text could potentially be intercepted by unauthorized individuals on the network.

It is possible to piece together a solution that partially addresses these issues, but pursuing such a path may prove detrimental overall. Often, attempts to achieve full functionality under these circumstances yield unsatisfactory results.

Answer №2

A unique identifier for a computer known as a MAC address can be used to determine whether to allow or reject connections.

The challenge arises because the MAC address cannot be accessed through JavaScript, requiring code execution outside the browser's security sandbox, such as a Java applet.

This limitation raises questions about why this is considered a web application if it can only function on a single computer.

Answer №3

Opting for pay-per-PC means a WebApp is not the ideal technology choice. Browsers are not designed to function in that manner. Consider altering either the licensing model or the technology used. For pay-per-PC, a thick client with activation is necessary.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Timers in ASP.NET Applications

In my asp.net application start event, I am trying to implement a Timer class for triggering events. Specifically, I want to execute one trigger every night at 11 pm, another at 5:30 in the morning, and then every hour thereafter. private System.Threading ...

Exploring the synchronization abilities of .NET 4.0 in a desktop application utilizing sqlite and a single thread

Are there any opportunities to implement parallelism, multi-threading, PLINQ, etc. in a single threaded WPF desktop application with SQLite integration? I am curious to explore and see if it is possible to enhance my application through optimization techn ...

Running a 2D JavaScript game script on a React page - A step-by-step guide!

I am facing a challenge with my website that features a game coded entirely in javascript. Despite my efforts to switch the site from an HTML layout to a more modern React design, I can't seem to get the game to display correctly. In the original HTM ...

Having trouble removing objects from a map results in having to invoke the function three times

I am facing an issue with the function findPrice where I need to call it multiple times to delete objects that match a specific price. The problem arises when dealing with large maps and two functions. Here is the JSON format: [ { _id: 5c6c408dbec3ab457c ...

Identifying the moment when the hide() function in jQuery is triggered for an element

Is there a way to detect when the .hide() method in jQuery is triggered on an element? I attempted to attach an event listener to the hide event of that particular element: $('div').bind('hide', function(){ alert("Hidden&q ...

Tally the lines in the textarea

I have a textarea that allows users to input up to 16 lines of text. I created a directive for this purpose, and it works well when the user hits the enter key. However, I also want to restrict the input to only 16 lines, even if the user enters a very lo ...

Current selection in a dynamic menu within an Express universe

In my Express.js app, I am working on creating a simple menu. My goal is to add the "active" class to the menu list item of the page that is currently being visited. Here is the code snippet from my Jade view file: li(class = path === "/id/admin" ? "activ ...

Can I bypass an invalid SSL certificate when making a request using a JavaScript library?

Is it possible to bypass invalid SSL certificates when using the widely-used request library? You can find more information about the library here: https://www.npmjs.com/package/request I am currently integrating this library into a Node.js server to send ...

Ways to update row background color based on specific column values

I need to customize the background color of my table rows based on the value in the "Category" column. For example: Name Category Subcategory A Paid B C Received D If the Category value is 'Paid', I want the ro ...

The retrieval of data using PHP, MYSQL, and AJAX is unsuccessful

A dropdown menu contains the names of months, represented by numbers from 1 to 12: When a month is selected, I want to retrieve data from a database to display relevant tournaments for that specific month. The SQL code has been tested and confirmed to be ...

What steps can you take to fix the error message "Cannot read properties of undefined"?

There seems to be a warning that I've encountered: [Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'nestedArray')" How can I resolve this issue? Here is my beforeCreate function: beforeCreat ...

Updating the title with respect to the current route in AngularJS 1

Is it possible to dynamically change the title displayed in a header based on the current route provided by the router, even when outside of the controller scope? For example, I have a mainMenu controller that is loaded when a specific route is called. The ...

Having trouble updating the value of my textfield in material-ui using formik

Below is the code I'm working with to set a default value using the material-ui Textfield API within a formik fieldarray: <TextField name={`myGroups.${index}.myGroupName`} value={`Group ${index+1}`} label="Group" InputProps={{ ...

Why aren't my Post Variables being passed through my jQuery Ajax Request?

My goal is to utilize a full calendar ajax call to add events to the database. After testing the PDO query separately and confirming its functionality, I have identified an issue with the ajax post. The code snippet below showcases the ajax call in defaul ...

Restrict Angular 2 Component to specific ancestor Component

Is it possible in Angular 2 to restrict a Component so that it can only appear within a specific parent element on a page? In other words, the Component should only be allowed if it has a certain parent element. Here is an example: Allowed: <parent> ...

Mastering the Art of Crafting Detailed Web Addresses

I have observed that numerous blogs utilize URLs in the following format: It seems like this is done for the purpose of search engine optimization. How exactly is this processed from the underlying data model? Do you actually search for VirtualCamarade ...

Autocomplete with Avatar feature in Material UI TextField

Is it possible to display an avatar in the text field of the autocomplete material-ui component when using the getOptionLabel prop, which only accepts a string? The expected UI shows a profile picture and name for each option. Can we achieve the same thi ...

The functionality to deactivate the Textbox when the Checkbox is checked is currently not functioning as expected

I wrote a script that disables textboxes whenever a checkbox is unchecked in a gridview: $(function () { //Enable or disable all textboxes when header row checkbox is checked. $("[id*=chkHeader]").on("click", function () { var chkHeader = $ ...

Guide on displaying an alert from a different code module in asp.net

Is there a way to display an alert from a separate code module in ASP.NET, rather than the code behind of a page? It seems straightforward when doing it from the code behind of a page. The following is one method to accomplish this: ScriptManager.Registe ...

What techniques can I use to modify an object while it's being iterated through?

I've been attempting to manipulate the object while looping through it, but unfortunately, it's not working. How can I modify it so that the constant patient includes the property lastActivity inside the this.model array? My code looks like this ...