cli

command
v0.0.0-...-28918d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2022 License: MIT Imports: 11 Imported by: 0

README

example CLI executable

Another example implementation can be found in the crypt.cli/sess.go CLI app.

The CLI app is generally useful for looking at and configuring or testing User salt/hash settings, verifying a generated user-password, etc; not intended for use with or as a companion to the web-app.

To compile:

go build ./examples/cli

Or use the build helper (bash) script ./do cli

./do cli

The tool allows you to (1) create a user/password which includes generation of a session for the user, (2) validate the user/password and (3) list all sessions including the user owning the session.

Apparently if you attempt to create the same user twice, it will fail to generate the user however creates a new session.
The cli tool was written just to test creation and validation of user passwords as well as GORM.

For example, after you compile the CLI app...

generate a user

./cli create -u admin -p password

generates the following output

{1 admin dW6tmIxySUoV9SJr5OJ9aYH1b35QzuqpSoxo1KmHVIw33FpdM6asZ+Q0uYEFZ2fb K0Bt+bF4qiTNYMkrJ3tF7RdxGBjuV0zsDpV4htJ2B+U=}
success: false; session={1 1 cli-example-app 2019-07-24 08:35:09.4055506 -0500 CDT m=+2.414109701 2020-01-24 08:35:09.4055506 -0600 CST RFNaT0JhQTNpM2xsRno0NmFkeURqdDJKeHpqRGxZQU8veUpjWnJocXkzSjYrR1BVUG8wejQ2QklJbzZ0NThSRA== dW5rbm93bi1jbGllbnQ= false}

verify user password

./cli validate -u admin -p doomedtofail

outputs

Result: false

Lets try the working "password"

./cli validate -u admin -p password

outputs the following success

Result: true

Finally, we can call the following to show each user-session stored in the sessions table including the user name.

./cli list

Documentation

Overview

Package main provides a CLI executable that at worked properly at some point but ATM, hasn't been tested since a number of changes had been implemented.

Though not thourally documented by the cli's `help` command, there are three sub-commands that can be used to test out the implemented crypto validiation.

  1. `sess.exe create -u <username> -p <password>` will create a user in the table `users` and also create a session in the `sessions` table.
  1. `sess.exe validate -u <username> -p <password>` will check and validate the provided password.
  1. `sess.exe list` will list the entries in the sessions table and provide the User.Name for each row.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL