• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language PLpgSQL
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

RFC6238 TOTP implementation in pure PostgreSQL plpgsql

totp Build Status

TOTP implementation in pure PostgreSQL plpgsql

This extension provides the HMAC Time-Based One-Time Password Algorithm (TOTP) as specfied in RFC 6238/4226 as pure plpgsql functions.

Usage

totp.generate

SELECT totp.generate('mysecret');

-- you can also specify totp_interval, and totp_length
SELECT totp.generate('mysecret', 30, 6);

In this case, produces a TOTP code of length 6

013438

totp.verify

SELECT totp.verify('mysecret', '765430');

-- you can also specify totp_interval, and totp_length
SELECT totp.verify('mysecret', '765430', 30, 6);

Depending on input, returns TRUE/FALSE

totp.url

-- totp.url ( email text, totp_secret text, totp_interval int, totp_issuer text )
SELECT totp.url(
    '[email protected]',
    'mysecret',
    30,
    'Acme Inc'
);

Will produce a URL-encoded string

otpauth://totp/[email protected]?secret=mysecret&period=30&issuer=Acme%20Inc

caveats

  • Currently only supports sha1
  • Currently only supports 20 byte secrets

pull requests welcome!

credits

Thanks to

https://tools.ietf.org/html/rfc6238

https://www.youtube.com/watch?v=VOYxF12K1vE

https://pgxn.org/dist/otp/

Development

start the postgres db process

First you'll want to start the postgres docker (you can also just use docker-compose up -d):

make up

install modules

Install modules

yarn install

install the Postgres extensions

Now that the postgres process is running, install the extensions:

make install

This basically sshs into the postgres instance with the packages/ folder mounted as a volume, and installs the bundled sql code as pgxn extensions.

testing

Testing will load all your latest sql changes and create fresh, populated databases for each sqitch module in packages/.

yarn test:watch

building new modules

Create a new folder in packages/

lql init

Then, run a generator:

lql generate

You can also add arguments if you already know what you want to do:

lql generate schema --schema myschema
lql generate table --schema myschema --table mytable

deploy code as extensions

cd into packages/<module>, and run lql package. This will make an sql file in packages/<module>/sql/ used for CREATE EXTENSION calls to install your sqitch module as an extension.

recursive deploy

You can also deploy all modules utilizing versioning as sqtich modules. Remove --createdb if you already created your db:

lql deploy awesome-db --yes --recursive --createdb

More Repositories

1

LaTeX2JS

LaTeX web components
JavaScript
607
star
2

vim3d

Vim3D is a viewer/graphical interpreter for 3D scene descriptions using C++ and OpenGL.
C++
66
star
3

Mathapedia

write LaTeX + PSTricks and produce digital textbooks with HTML5 interactivity :)
JavaScript
63
star
4

LaTeX2HTML5

LaTeX and PSTricks rendering for the Web
62
star
5

faker

create fake data in PostgreSQL
PLpgSQL
28
star
6

graphile-column-privileges-mutations

enable use of column-level SELECT grants, while still providing auto-generated mutations within PostGraphile
JavaScript
11
star
7

mathjax-iOS

JavaScript
8
star
8

skitch

build versioned PostgreSQL apps fast
TypeScript
7
star
9

inflection

inflection is a port of the functionality from Ruby on Rails' Active Support Inflection classes into PostgreSQL
PLpgSQL
5
star
10

mathjax-iOS-test

JavaScript
4
star
11

base32

RFC4648 Base32 encode/decode in plpgsql
PLpgSQL
4
star
12

cosmology

TypeScript
3
star
13

GLQuery

An extension of Mr. Doob's three.js
JavaScript
3
star
14

TouchJSON-ASIHTTP-scaffold

an xcode project with TouchJSON and ASIHTTP configured and ready to go
Objective-C
3
star
15

inquirerer

inquirer wrapper with overrides
TypeScript
2
star
16

etag-hash

Es6 class that generates ETag using the same algorithm as S3 via MD5 sum.
JavaScript
2
star
17

kavajs

TypeScript
2
star
18

webvize

JavaScript
2
star
19

stargazejs

TypeScript
2
star
20

graphile-postgis

JavaScript
1
star
21

thorchain

TypeScript
1
star
22

denarius-docker

docker based denarius wallet w local persistent data dir
Shell
1
star
23

pg-utils

PLpgSQL
1
star
24

uploads

πŸš€ πŸ“¦ ⚑️
CSS
1
star
25

PhiloGL-drag-n-drop-OBJ-Loader

JavaScript
1
star
26

MusicServer

JavaScript
1
star
27

stream-to-etag

Calculates Etag/S3 MD5 sum given a readable stream. Uses the same algorithm as S3.
JavaScript
1
star
28

dotfiles

Shell
1
star
29

mn-setup-scripts

Python
1
star
30

cosmjson

JavaScript
1
star
31

postgres-plv8

Postgres 10 + plv8 v2.3.0 + Docker
Makefile
1
star
32

osmojs-beta-testing

TypeScript
1
star
33

interchain46

TypeScript
1
star
34

scenicgps

JavaScript
1
star
35

babel-ast-example

JavaScript
1
star
36

graphile-column-select-grants-example

JavaScript
1
star
37

pg-query-context

πŸš€ queries in pg with context
JavaScript
1
star
38

nuxt-latex2vue-template

Nuxt.js starter project template for latex2vue (latex2js)
Vue
1
star
39

pg-units

PLpgSQL
1
star
40

gnojs

TypeScript
1
star
41

phoenix

Simple project to combine Protovis, Google Maps API, and the GeoHash algorithm.
JavaScript
1
star
42

graphile-search-plugin

JavaScript
1
star