MyNixOS website logo
Description

Command-line tool to manage Snap AuthManager database.

This utility provides command-line interface to user database of standard authentication system for the Snap web framework. You can create, read and update users, set passwords, roles and meta information. Currently only JsonFile backend is supported. Type `snap-auth-cli -?` to get usage information, or see README.md for details.

snap-auth-cli: CLI tool to manage Snap auth database

Travis CI build status Hackage Hackage deps

This tool provides command-line interface to Haskell SnapAuthManager to create, view and delete users in database. Currently the Json and Sqlite file backends are supported.

Passwords for new users are provided in plain text.

By default the database resides in current directory in users.json file. A different db may be specified using -f flag. To specify a Sqlite database use -s -f filename.

How to use

Type snap-auth-cli --help to get usage help.

Create a user:

$ snap-auth-cli --create -u TwasBrillig -p SlithyToves1855

User roles may be set when creating account using arbitary number of -o flags:

$ snap-auth-cli --create -u TwasBrillig2 -p SlithyToves1855 -o gyre -o gimble

A user may have an arbitary number of key-value pairs attached in the meta field (currently all fields are stored in Strings):

$ snap-auth-cli --create -u AlexP -p 1234 -k number -v 3214 -k foo -v bar -o admin

Read a user from DB (--read flag may be omitted since reading is the default mode):

$ snap-auth-cli --read -u AlexP
{
    "meta": {
        "number": "3214",
        "foo": "bar"
    },
    "suspended_at": null,
    "roles": [
        "admin"
    ],
    "pw": "sha256|12|VpUGBg2O/NBkDTVTSqqYuA==|TIDuc3ToAPmALXCHBxTA8SjlUBztPS8nH6qiV63a+f4=",
    "activated_at": null,
    "current_ip": null,
    "locked_until": null,
    "updated_at": "2012-02-22T09:00:29.377Z",
    "login_count": 0,
    "current_login_at": null,
    "login": "AlexP",
    "remember_token": null,
    "failed_login_count": 0,
    "last_ip": null,
    "last_login_at": null,
    "uid": "1",
    "created_at": null
}

To specify a different database file (Json by default):

$ snap-auth-cli -f back.json --create -u MimsyBorogove -p 0utgr@b3d

Note that if database file doesn't exist, it will be created from scratch.

To specify a Sqlite database:

$ snap-auth-cli -s -f db.sqlite --read -u AlexP

Unlike the Json backend, the database file with the correct schema must aleady exist; this should be automaticallly initialized by when you first run the Snap application.

Existing users can be modified using the -m option. User is selected by login. Any of -p, -o or -k/-v flags may be specified to set new value for user password, roles or meta. If no new value is provided, old field is preserved.

Set a new password for user:

$ snap-auth-cli -m -u Mome -p r@th$$

Set a new role:

$ snap-auth-cli -m -u Mome -o foobarer

Replace user meta:

$ snap-auth-cli -m -u BG -k tel -v 2-12-85-06

The tool provides interface to delete users; the Sqlite backend supports this operation but the JsonFile backend does not.

Metadata

Version

0.2

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows