Skip to content

harshsinghvi/golang-fido2-passkeys-api

Repository files navigation

golang2-fido-passkeys-api

Passwordless FIDO Passkey API in golang, Passwordless future

Deployment

  • elasticemail.com
  • render.com
  • supabase.com

Documentation to be updated soon

  • WIP: Documentation

Usecases

  • CLI Apps suthentication like ssh
  • Mobile based passkeys (Passwordless authentication)

CLI Usage

go install github.com/harshsinghvi/golang-fido2-passkeys-api/cli # install locally after cloning
go install github.com/harshsinghvi/golang-fido2-passkeys-api/cli@latest # install directly

cli decrypt -c challenge-string # manually decrypt challenge string and solve manually too
cli sign -m challenge-solution # sign the challenge solution

cli gen # generate RSA keys
cli register -n "User fullname" -e "user email" --server-url http://localhost:8080 # register user with previously generated rsa keys and verify challenge
cli register-new-key -e email -d description --server-url http://localhost:8080 # add key to user account
cli login --server-url http://localhost:8080 # login user using stored keys
cli logout # Business logic
cli get-me # Business logic

this creates $HOME/.FIDO2 Folder with rsa keys and config.yml file you can import or export keys in this folder

  • passkey.pem - private key
  • passkey.pub - public key
  • config.yml - config file (not to be edited)

Build Multi Arch Binary for CLI and Server

TODO

  • Add Event Status to all postEvent occurances, (failed / success)

  • check public key encoding

  • async logging

  • orgs

  • error handeling

  • rate limit

  • user preferneces

  • check BillingDisable

  • Workflow for releasing binaries

  • token roles

  • clean code in cli and crypto library

  • make new repos for cli and autoroutes routes UI

  • admin portal

  • org login

  • WIP: Documentation

TEST DB

-- make changes in this

CREATE DATABASE test_db_savepoint; 

create test db from savepoint

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity 
WHERE pg_stat_activity.datname in ('test_db_savepoint' ,'test_db') AND pid <> pg_backend_pid();

CREATE DATABASE test_db WITH TEMPLATE test_db_savepoint OWNER postgres;

reset to savepoint

SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity 
WHERE pg_stat_activity.datname in ('test_db_savepoint' ,'test_db') AND pid <> pg_backend_pid();
DROP DATABASE test_db;
CREATE DATABASE test_db WITH TEMPLATE test_db_savepoint OWNER postgres;

hard delete

DELETE FROM access_logs WHERE deleted_at IS NOT NULL;
DELETE FROM access_tokens WHERE deleted_at IS NOT NULL;
DELETE FROM challenges WHERE deleted_at IS NOT NULL;
DELETE FROM events WHERE deleted_at IS NOT NULL;
DELETE FROM passkeys WHERE deleted_at IS NOT NULL;
DELETE FROM users WHERE deleted_at IS NOT NULL;
DELETE FROM verifications WHERE deleted_at IS NOT NULL;

hard delete All

DELETE FROM access_logs;
DELETE FROM access_tokens;
DELETE FROM challenges;
DELETE FROM events;
DELETE FROM passkeys;
DELETE FROM users;
DELETE FROM verifications;

Drop All tables

DROP TABLE access_logs;
DROP TABLE access_tokens;
DROP TABLE challenges;
DROP TABLE events;
DROP TABLE passkeys;
DROP TABLE users;
DROP TABLE verifications;