Skip to content

A module that makes totp authentication possible in PocketBase

Notifications You must be signed in to change notification settings

raizdev/pocketbase-totp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pocketbase-totp

A module that makes totp authentication possible in PocketBase

VueJS integration

Example how to integrade it with VueJS https://github.com/raizdev/pocketbase-totp-vue

Run and build golang

  1. To init the dependencies go mod init myapp && go mod tidy

  2. To start the application go run main.go serve

  3. To build a statically linked executable You can run CGO_ENABLED=0 go build and then start the created executable with ./myapp serve.

Installation

Create text field in user collection and define the field name in secretField variable in .env file

Integration in JS App

   pb.send('/auth-generate-totp')

Remove TOTP secret code for user in pocketbase

   pb.send('/auth-remove-totp', { method: "POST", body: { totpCode: "214142" } })

Activate TOTP for user and generates secretcode and store user in pocketbase

   pb.send('/auth-activate-totp', { method: "POST", body: { secret: "ABCODI2928D", issuer: "fixedserver.dev", totpCode: "214142" } })

Login with TOTP totpCode attr must always be provided even when user don't have totp active. If user has totp active status: authenticator_enabled will be returned. Store email and user password and set totpcode which inserted by user. Token and record will be returned after succesfull login

   const auth = pb.send('/auth-login-totp', { method: "POST", body: { email: "[email protected]", password: "test1234", totpCode: "" } })

   # to store record in authstore
   pb.authStore.save(auth.token, auth.record)

About

A module that makes totp authentication possible in PocketBase

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages