Geo-fencing Wasn't Enough: My Introduction to WebAuthn
How I combined location-based verification and password-less authentication while building an employee attendance tracking system. Imagine you're building an attendance tracking system for a company. The objective see
How I combined location-based verification and password-less authentication while building an employee attendance tracking system.
Imagine you're building an attendance tracking system for a company.
The objective seems straightforward: employees should be able to clock in when they arrive at the office, while administrators get a dashboard showing who's present, who's late, and how the organization is doing in terms of attendance.
Simple enough, right?
When I started working on an attendance tracking application, I quickly realized that recording someone's arrival time was only part of the problem. I also needed to establish whether the person checking in was actually at the office and, more importantly, whether they were the employee they claimed to be.
My first question was simple:
How do I know an employee is physically within the office premises when they clock in?
There's little point building an attendance tracking system if someone can comfortably sign in from their bedroom while the rest of the team is already at work.
My first solution was geo-fencing.
But solving that problem introduced another one.
Let's say Employee A is running late and decides to give their login credentials to Employee B, who is already at the office. Employee B logs in on their behalf, and as far as the system is concerned, Employee A has successfully checked in.
The location is correct. The identity isn't.
That got me thinking: How do I verify not just where someone is, but whether they're actually the person they're claiming to be?
That's how I came across WebAuthn.
In this article, I'll walk you through how geofencing and WebAuthn work, why I considered combining them for my attendance tracking application, and some things worth considering before introducing either technology into your next project.
Let's get into it.
Understanding WebAuthn: Authentication Without Passwords
You've probably spent time browsing websites, making payments, streaming music, or watching videos. More often than not, when you need to sign in, a website asks you to provide your email address and password.
That's the traditional password-based authentication model.
However, you've probably also encountered services that allow you to sign in without manually entering a password. Instead, they might ask you to use your fingerprint, face recognition, a device PIN, or a security key.
So, how does that work?
To understand this, let's talk about your smart devices: your smartphone, tablet, laptop, and other devices.
These devices contain built-in security mechanisms, such as secure hardware or operating-system-managed authenticators, that can generate and protect cryptographic credentials.
This brings me to the question:
What exactly is WebAuthn, and what does it have to do with all this?
WebAuthn, short for Web Authentication, is a web standard developed through the W3C and FIDO ecosystem. It allows web applications to authenticate users using public-key cryptography rather than relying exclusively on passwords.
In simple terms, instead of proving who you are by sending a password to a website, your device proves that it has access to a cryptographic private key associated with your account.
That probably sounds like a lot of technical mumbo jumbo, so let's break it down.
- Registration: Generating a Key Pair
When you register a WebAuthn credential on a website, your authenticator generates a cryptographic key pair:
Private key: This stays protected by the authenticator and is used to sign authentication challenges.
Public key: This is sent to the website and stored on its server.
Think of the public key as something the website can use to verify your identity, while the private key is the secret that allows your authenticator to prove possession of the credential.
The important thing to understand is that the private key is not sent to the website.
- Authentication: Proving Possession of the Private Key
When you want to log in, the website generates a random cryptographic challenge and sends it to your browser.
Your authenticator uses the corresponding private key to sign that challenge.
The signed response is then sent back to the website, where the server verifies it using the public key stored during registration.
If the signature is valid and the other authentication checks pass, the website can establish that the authentication request was signed using the private key associated with that credential.
In other words, the website doesn't need to know your private key. It only needs to verify the signature.
- Hardware and Biometrics: How Do You Actually Authenticate?
This is probably the part you're most familiar with.
When using WebAuthn, authentication can involve your device's built-in security features, such as:
Fingerprint recognition (Touch ID or Android bio-metrics).
Facial recognition (Face ID or Windows Hello).
A device PIN.
An external physical security key, such as a YubiKey.
These mechanisms help the authenticator verify that someone is authorized to use the credential.
Here's an important distinction: WebAuthn doesn't necessarily receive or process your fingerprint or facial data. Bio-metric verification typically happens locally on the device or authenticator. Your application receives the cryptographic authentication result, not the employee's bio-metric information.
Also, not every WebAuthn authentication requires bio-metrics. Depending on the authenticator and its configuration, a PIN or another verification mechanism may be used.
That's the beauty of WebAuthn. It allows applications to rely on strong cryptographic authentication without having to collect or store users' passwords.
And if you've found this article insightful so far, leave a heart (reaction) and a comment. It encourages me to keep writing. Don't forget to share it, too. Someone in your network might need this!
Why WebAuthn Instead of the Traditional Email and Password Combination?
You might be wondering why I would introduce WebAuthn when a traditional email and password combination could do the job.
Well, let me explain how I arrived at that decision.
You see, I was given a task to build an attendance tracking application.
If you work in a corporate environment, you probably understand how attendance tracking works. If you don't, here's some context.
Organizations often need to keep records of when employees arrive at work. These records help management monitor attendance, identify lateness, and get an overview of general office activity.
Traditionally, some organizations rely on attendance registers where employees manually write down their arrival times.
But there's a problem with that approach: anyone can write down almost any time, provided nobody catches them.
The goal of the application was to eliminate that unnecessary manual process, make attendance records more reliable, and provide administrators with a dashboard where they could monitor employee attendance at a glance.
When I started building it, my first concern was location.
How do I ensure that employees can only clock in when they're actually within the office premises?
What's the point of having an attendance tracking application if employees can sign in from their homes?
That's where Geo-fencing came in.
Geo-fencing: Making Location Part of the Authentication Process
So, what exactly is Geo-fencing?
Geo-fencing is a location-based technology that creates a virtual boundary around a real-world geographical area.
When a device enters or leaves that boundary, an application can detect the event and trigger a predefined action.
For example, imagine creating a virtual boundary around your office premises. Whenever an employee attempts to clock in, the application checks their current location against the office's predefined coordinates.
If they're within the permitted boundary, the application allows them to proceed. Otherwise, the check-in request is rejected.
That was exactly what I wanted.
I needed a way to prevent employees from checking in unless they were physically present at the office.
Implementing Geo-fencing
I won't go into the entire development process, but if you're considering implementing something similar in your next project, there are a few things worth knowing.
First, you'll need a way to store the office's geographical coordinates and the configuration required for your location checks.
For my implementation, I worked with predefined environment variables:
LAT: The office's latitude.
LONG: The office's longitude.
ACCURACY: The acceptable location accuracy threshold.
RADIUS_METERS: The permitted distance from the office coordinates.
You'll also need to obtain the employee's current geographical coordinates when they attempt to clock in.
For distance calculation, I used the Haversine formula.
If you're unfamiliar with it, the Haversine formula calculates the great-circle distance between two points on the surface of a sphere using their latitude and longitude coordinates.
In this case, it helps determine how far an employee's reported location is from the office.
The application can then compare that distance against the predefined radius.
If the employee's location falls within the permitted radius, the location check passes.
If it falls outside the radius, the application rejects the check-in attempt.
It took a little bit of tinkering because I was working with CakePHP, but after some time, I got it working.
Problem solved, right?
Not quite.
The Problem with Location: Who Is Actually Checking In?
After getting Geo-fencing to work, another question came to mind.
Let's assume we have two employees, A and B.
Employee A is running late and decides to give Employee B their login credentials so B can check in on their behalf.
Employee B is already at the office, so they log in using A's credentials.
The location check passes because B is physically within the office premises.
The login succeeds because B has A's credentials.
But Employee A isn't actually there.
See the problem?
Geo-fencing had successfully answered one question:
Is the device being used to check in within the office's geographical boundary?
But it couldn't reliably answer another:
Is the person checking in actually the employee associated with the account?
I realized that I needed another layer of verification.
I also started thinking about restricting employees to a limited number of registered devices.
That was when I discovered WebAuthn and began exploring how I could use it to strengthen the authentication process.
Now we're all caught up.
Combining Geo-fencing and WebAuthn
At this point, the idea was to use both technologies to address two different aspects of the attendance tracking problem.
Geo-fencing would help establish whether the device was within the permitted office area.
WebAuthn would provide stronger authentication by requiring the employee to prove possession of a registered cryptographic credential.
Here's how the process could work:
An employee opens the attendance application and attempts to clock in.
The application requests the device's current geographical location.
The backend checks the reported coordinates against the office's predefined location and permitted radius.
If the location check passes, the application initiates a WebAuthn authentication challenge.
The employee authenticates using their registered authenticator, such as a fingerprint, device PIN, facial recognition, or security key.
The backend verifies the signed response using the employee's registered public key.
If both checks pass, the application records the employee's attendance.
The result is a system that checks both location and possession of a registered authentication credential.
However, there's an important distinction worth making here.
WebAuthn doesn't magically establish a person's real-world identity. It proves that the authentication request was authorized using a registered credential and, when configured appropriately, that the authenticator performed user verification.
If an employee shares their unlocked device or someone else can satisfy its authentication requirements, impersonation may still be possible.
So, while WebAuthn significantly strengthens authentication, it shouldn't be treated as an absolute guarantee that the account owner is physically holding the device.
Does WebAuthn Actually Restrict Employees to One Device?
This is another important consideration.
One of the reasons I became interested in WebAuthn was the possibility of limiting employees to registered devices.
However, there's a technical distinction worth understanding.
A WebAuthn credential is not simply a hardware ID that uniquely identifies a smartphone or laptop.
It's a cryptographic credential associated with a relying party (the website or application requesting authentication).
An employee can potentially register multiple credentials, and some passkeys can be synchronized across multiple devices through a platform's credential-management ecosystem.
This means that simply implementing WebAuthn does not automatically enforce a one-device-per-employee policy.
If restricting device usage is a requirement, you'll need to design an appropriate credential-registration and management policy.
For example, you could:
Limit the number of active credentials registered to each employee(an extra approach I took).
Require administrative approval before registering a replacement device.
Allow employees to revoke lost or compromised credentials.
Consider device-bound credentials where supported and appropriate for your environment.
Evaluate authenticator attestation if you have a genuine requirement to enforce particular authenticator characteristics, while considering its compatibility and privacy implications.
The important thing is to understand that WebAuthn provides the cryptographic authentication mechanism. Your application still needs to implement the business rules around which credentials employees are allowed to use.
When Should You Consider Using WebAuthn?
Now that we've established what WebAuthn does and how it fits into my use case, let's look at some situations where it might make sense to introduce it into your own projects.
- Password-less Sign-In (Passkeys)
If you want users to sign in without remembering or manually entering passwords, WebAuthn is worth considering.
With passkeys, users can authenticate using supported bio-metrics, a device PIN, or a physical security key.
This reduces dependence on traditional passwords and makes the login experience more convenient.
- Phishing-Resistant Multi-Factor Authentication
Traditional authentication methods, such as SMS one-time passwords (OTPs), can be vulnerable to phishing and interception.
WebAuthn offers strong phishing resistance because credentials are scoped to the website's relying-party identity.
In simple terms, a credential registered for your legitimate website cannot normally be used by a fake website pretending to be yours.
This makes WebAuthn a particularly useful option when building applications that require stronger authentication.
- Enterprise and High-Security Applications
WebAuthn is also useful in environments where access to sensitive information or systems needs to be carefully controlled.
Examples include:
Corporate applications.
Internal administrative dashboards.
Enterprise identity systems.
Customer portals containing sensitive information.
Systems that support hardware security keys, such as YubiKeys.
In these environments, WebAuthn can provide a stronger authentication foundation than password-only login.
Things to Consider Before Combining Geo-fencing and WebAuthn
Like every other technology, geo-fencing and WebAuthn come with their own trade-offs.
Before introducing them into your next project, there are a few things worth considering.
- Location Data Isn't Always Accurate
Geo-fencing depends on location information provided by a device.
However, GPS accuracy can vary depending on the environment. Buildings, poor satellite visibility, network conditions, and indoor positioning limitations can affect the reported coordinates.
The browser's Geo-location API also doesn't guarantee that the location it returns is the device's actual physical location.
Depending on the threat model, location data can also be manipulated.
This means you shouldn't blindly trust a location response simply because it falls within your predefined radius.
Consider checking the reported accuracy, rejecting stale location readings, and introducing additional safeguards where necessary.
- WebAuthn Doesn't Guarantee the Human Identity
WebAuthn proves possession of a cryptographic credential and can require local user verification.
However, it doesn't independently establish that the person using the authenticator is the employee whose account is being accessed.
For example, an employee could share an unlocked device with someone else, or another person could know the device PIN.
It's important to understand what WebAuthn guarantees and what remains the responsibility of your application.
- Device Compatibility and Credential Management
Not all devices and browsers offer exactly the same authentication capabilities.
Some employees might use older devices, while others might have different operating systems or authenticators.
You'll also need to think about what happens when an employee loses their device, changes phones, or needs to register a replacement security key.
Having a recovery and credential-revocation process is just as important as implementing the authentication flow itself.
- Privacy and Employee Experience
Location tracking and authentication introduce privacy considerations, particularly in workplace environments.
Employees should understand what location information is collected, when it's collected, why it's needed, and how long it's retained.
Ideally, location should only be requested when it's necessary for the attendance process rather than continuously tracking employees throughout the day.
You should also consider how the application handles employees whose devices cannot obtain sufficiently accurate location readings.
After all, the goal is to improve attendance management, not create unnecessary frustration for employees.
So, Should You Use WebAuthn and Geo-fencing?
Well, that depends.
Like every other technology, WebAuthn and geo-fencing have their strengths and limitations.
They introduce additional implementation considerations, compatibility requirements, and, in some cases, operational complexity.
The goal shouldn't be to use a technology simply because it's new, popular, or sounds impressive on your tech stack.
Instead, understand the problem you're trying to solve and determine whether the technology actually addresses it.
In my case, Geo-fencing helped address the question of location, while WebAuthn introduced a stronger way to authenticate employees without relying on shared passwords.
Together, they provide useful building blocks for a more trustworthy attendance tracking system.
But neither is a silver bullet.
Geo-fencing doesn't guarantee that a device is physically where it claims to be, and WebAuthn doesn't guarantee that the person authenticating is the rightful owner of the account.
What they do is reduce different categories of risk when implemented correctly.
And that's really the lesson here:
Security isn't just about knowing where a request comes from. It's also about establishing who is making that request and whether they're authorized to make it.
I'd love to hear your thoughts!
Have you worked with WebAuthn or geo-fencing before? Have you implemented either technology in a real-world application? If you have, what challenges did you encounter?
Feel free to share your experiences, suggestions, or even alternative approaches in the comments.
If you found this article helpful, leave a heart and share it with someone who might find it useful, too.
See you in the next one! 😁
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.
