--- title: "Stop Hashing Passwords: A Practical Step-by-Step Passkey Tutorial" author: "Alain Airom (Ayrom)" published: "2026-09-11T05:09:59.208Z" updated: "2026-09-11T05:09:59.208Z" url: "https://zyvop.com/stop-hashing-passwords-a-practical-step-by-step-passkey-tutorial-ora6j" canonical: "https://dev.to/aairom/stop-hashing-passwords-a-practical-step-by-step-passkey-tutorial-2eab" tags: ["go","Software","passkey","security","bob"] --- # Stop Hashing Passwords: A Practical Step-by-Step Passkey Tutorial ![Cover image]() Code-First Security: A Practical Implementation of a Go Passkey Manager ![ ]() ## Introduction — What are ‘Passkeys’ and why should we use them? I was asked by a young student asking me about passkeys, why we should use them, so I decided to implement a sample code to make a demonstration. This simple question highlights a major shift in digital security: we are finally moving away from the era of shared secrets. While passwords require us to memorize complex strings — which we inevitably reuse or forget — passkeys leverage asymmetric cryptography to create a login experience that is both more secure and significantly more convenient. The core advantage of passkeys lies in their phishing resistance. Because a passkey is tied to a specific domain and never leaves your physical device, a malicious website cannot “trick” you into giving up your credentials. Furthermore, passkeys eliminate the risk of server-side data breaches; since the server only stores a public key rather than a password hash, there is no “secret” for a hacker to steal. By replacing manual entry with biometrics like FaceID or TouchID, passkeys offer a seamless “zero-friction” workflow that proves security doesn’t always have to come at the cost of user experience. * * * ## Why Passkeys Win: A Quick Comparison ```markdown | Feature | Traditional Passwords | Passkeys (WebAuthn) | | ----------------------- | ---------------------------------------------------- | ------------------------------------------------------ | | **Authentication Type** | Knowledge (What you know) | Possession + Inherence (What you have + Who you are) | | **Phishing Protection** | **Low:** Users can be tricked into typing passwords. | **High:** Cryptographically bound to the real website. | | **Data Breach Risk** | **High:** Stolen hashes can be cracked offline. | **None:** Public keys are useless to an attacker. | | **User Experience** | **Frustrating:** Requires managers or memory. | **Seamless:** Uses device biometrics or PINs. | ``` Enter fullscreen mode Exit fullscreen mode * * * ## Sample Application to showcase a practical ‘Passkey’ implementation ![ ]() To transform the abstract theory of FIDO2 into a tangible learning tool, I collaborated with **IBM Bob** to architect a functional passkey demonstration. The system utilizes a robust **Go** backend to manage the complex WebAuthn handshake, paired with a clean **HTML/JavaScript** frontend for a transparent user experience. During my testing, the application generated passkeys seamlessly, which I was able to store securely within my **Bitwarden** manager — proving that these ‘hardware-backed’ credentials integrate perfectly with modern security workflows. For those looking to dive deeper into the ‘how’ and ‘why,’ Bob has produced comprehensive documentation within the project, including a Quick Start Guide and detailed Architecture Diagrams, ensuring the mechanics are as clear as the implementation itself. ## Project Breakdown at a Glance ![ ]() Based on the project files, here is how the educational application is structured: ```python passkey-demo/ ├── server/ # Go backend server │ ├── main.go # Server entry point │ ├── handlers.go # HTTP handlers │ ├── storage.go # In-memory storage │ ├── go.mod # Go dependencies │ └── go.sum # Dependency checksums ├── client/ # HTML/JavaScript client │ ├── index.html # Main page │ ├── register.html # Registration page │ └── login.html # Login page ├── k8s/ # Kubernetes manifests │ ├── namespace.yaml # Namespace definition │ ├── configmap.yaml # Configuration │ ├── deployment.yaml # Deployment spec │ ├── service.yaml # Service definition │ ├── ingress.yaml # Ingress rules │ ├── hpa.yaml # Horizontal Pod Autoscaler │ └── README.md # K8s deployment guide ├── Dockerfile # Container image definition ├── .dockerignore # Docker ignore rules ├── docker-compose.yml # Docker Compose configuration ├── start.sh # Start script (detached mode) ├── stop.sh # Stop script ├── ARCHITECTURE.md # Architecture diagrams (Mermaid) ├── QUICKSTART.md # Quick start guide ├── SETUP.md # Detailed setup instructions ├── API.md # API documentation └── PROJECT_OVERVIEW.md # Comprehensive overview ``` Enter fullscreen mode Exit fullscreen mode - **The Backend (Go)**: A RESTful API that leverages the go-webauthn library to handle registration and login challenges. ```go package main import ( "log" "net/http" "os""github.com/go-webauthn/webauthn/webauthn" "github.com/gorilla/mux") func main() { // Get configuration from environment or use defaults rpID := getEnv("RP_ID", "localhost") rpOrigin := getEnv("RP_ORIGIN", "http://localhost:8080") port := getEnv("PORT", "8080")// Initialize WebAuthn wconfig := &webauthn.Config{RPDisplayName: "Passkey Demo",RPID: rpID,RPOrigins: []string{rpOrigin},// Timeout for registration/authentication (in milliseconds)Timeouts: webauthn.TimeoutsConfig{ Login: webauthn.TimeoutConfig{ Enforce: true, Timeout: 60000, TimeoutUVD: 60000, }, Registration: webauthn.TimeoutConfig{ Enforce: true, Timeout: 60000, TimeoutUVD: 60000, },}, }webAuthn, err := webauthn.New(wconfig) if err != nil {log.Fatalf("Failed to create WebAuthn instance: %v", err) }// Initialize storage storage := NewStorage()// Initialize handlers handlers := NewHandlers(webAuthn, storage)// Setup router r := mux.NewRouter()// API routes api := r.PathPrefix("/api").Subrouter() api.HandleFunc("/register/begin", handlers.RegisterBegin).Methods("POST", "OPTIONS") api.HandleFunc("/register/finish", handlers.RegisterFinish).Methods("POST", "OPTIONS") api.HandleFunc("/login/begin", handlers.LoginBegin).Methods("POST", "OPTIONS") api.HandleFunc("/login/finish", handlers.LoginFinish).Methods("POST", "OPTIONS")// Health check endpoint r.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {w.WriteHeader(http.StatusOK)w.Write([]byte("OK")) }).Methods("GET")// Serve static files from client directory clientDir := "../client" if _, err := os.Stat(clientDir); err == nil {r.PathPrefix("/").Handler(http.FileServer(http.Dir(clientDir)))log.Printf("Serving static files from %s", clientDir) } else {log.Printf("Client directory not found at %s, skipping static file serving", clientDir) }// Apply middleware handler := LoggingMiddleware(EnableCORS(r))// Start server log.Printf("Starting server on port %s", port) log.Printf("RP ID: %s", rpID) log.Printf("RP Origin: %s", rpOrigin) log.Printf("API endpoints:") log.Printf(" POST /api/register/begin") log.Printf(" POST /api/register/finish") log.Printf(" POST /api/login/begin") log.Printf(" POST /api/login/finish") log.Printf(" GET /health")if err := http.ListenAndServe(":"+port, handler); err != nil {log.Fatalf("Server failed to start: %v", err) }} // getEnv gets an environment variable or returns a default valuefunc getEnv(key, defaultValue string) string { value := os.Getenv(key) if value == "" {return defaultValue } return value} // Made with Bob ``` Enter fullscreen mode Exit fullscreen mode - **The Frontend (Vanilla JS)**: Uses the native `navigator.credentials` browser API to talk to your biometrics or security keys. ![ ]() ```bash Register - Passkey Demo

🔐 Register

Create a new account with a passkey

How it works: Enter your username and click register. You'll be prompted to create a passkey using your device's biometric sensor, security key, or PIN.

Creating your passkey...

``` Enter fullscreen mode Exit fullscreen mode - **Storage Strategy**: Currently uses in-memory storage for simplicity, making it a perfect “sandbox” for students to experiment without database overhead. ![ ]() ![ ]() - **Deployment Versatility**: Bob has configured the app to run via a simple script (`start.sh`), Docker, or even Kubernetes for more advanced learners. ```markdown # Multi-stage build for smaller final imageFROM golang:1.21-alpine AS builder # Install build dependenciesRUN apk add --no-cache git ca-certificates tzdata # Set working directoryWORKDIR /build # Copy go mod filesCOPY server/go.mod server/go.sum ./ # Download dependenciesRUN go mod download # Copy source codeCOPY server/ ./ # Build the applicationRUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-w -s" -o passkey-demo . # Final stage - minimal imageFROM alpine:latest # Install ca-certificates for HTTPSRUN apk --no-cache add ca-certificates tzdata # Create non-root userRUN addgroup -g 1000 appuser && \ adduser -D -u 1000 -G appuser appuser # Set working directoryWORKDIR /app # Copy binary from builderCOPY --from=builder /build/passkey-demo . # Copy client filesCOPY client/ ./client/ # Change ownership to non-root userRUN chown -R appuser:appuser /app # Switch to non-root userUSER appuser # Expose portEXPOSE 8080 # Health checkHEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \ CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1 # Set environment variablesENV RP_ID=localhost \ RP_ORIGIN=http://localhost:8080 \ PORT=8080 # Run the applicationCMD ["./passkey-demo"] ``` Enter fullscreen mode Exit fullscreen mode ```markdown apiVersion: apps/v1kind: Deploymentmetadata:name: passkey-demonamespace: passkey-demolabels: app: passkey-demospec:replicas: 3selector: matchLabels: app: passkey-demotemplate: metadata: labels: app: passkey-demo spec: containers: - name: passkey-demo image: passkey-demo:latest imagePullPolicy: IfNotPresent ports: - containerPort: 8080 name: http protocol: TCP env: - name: RP_ID valueFrom: configMapKeyRef: name: passkey-demo-config key: RP_ID - name: RP_ORIGIN valueFrom: configMapKeyRef: name: passkey-demo-config key: RP_ORIGIN - name: PORT valueFrom: configMapKeyRef: name: passkey-demo-config key: PORT resources: requests: memory: "64Mi" cpu: "100m" limits: memory: "128Mi" cpu: "200m" livenessProbe: httpGet: path: /health port: 8080 initialDelaySeconds: 10 periodSeconds: 30 timeoutSeconds: 3 failureThreshold: 3 readinessProbe: httpGet: path: /health port: 8080 initialDelaySeconds: 5 periodSeconds: 10 timeoutSeconds: 3 failureThreshold: 3 securityContext: runAsNonRoot: true runAsUser: 1000 allowPrivilegeEscalation: false readOnlyRootFilesystem: false capabilities: drop: - ALL # Made with Bob ``` Enter fullscreen mode Exit fullscreen mode ![ ]() * * * ## Understanding the “Bitwarden” Connection When you store a passkey in Bitwarden during this demo, you are witnessing cross-platform passkey support. The Go server sends a challenge, and instead of your laptop’s local chip (TPM) answering, your Bitwarden browser extension intercepts the request, signs it, and saves the private key. * * * ## Conclusion In conclusion, the fundamental principle of passkeys represents a paradigm shift from “something you know” to “something you have” and “something you are,” replacing vulnerable shared secrets with robust asymmetric cryptography. This demonstration application successfully showcases the efficiency of this transition by distilling a complex security protocol into a frictionless, one-touch experience. By removing the burden of password creation and management while simultaneously neutralizing the threat of phishing and server-side breaches, the project proves that high-level security does not have to compromise user convenience. As users seamlessly generate and store these credentials in tools like Bitwarden, it becomes clear that passkeys are not just a theoretical improvement, but a practical, ready-to-use standard for a more secure digital future. **\>>> Thanks for reading 🔐 <<<** ## Links - Repository of this demonstration: [https://github.com/aairom/passkey-demo]() - Web authentication explananation: [https://webauthn.guide/]() - Fido alliance: [https://fidoalliance.org/]() - Go Webauthnetication Library used: [https://github.com/go-webauthn/webauthn]()