Giter VIP home page Giter VIP logo

otsgo's Introduction

OTS Go client

otsgo is a simple CLI and API client for One-Time Secret written in Go.

Features

  • Get system status
  • Authentication
  • Share, generate, get and burn Secrets as well as retrieve it's metadata

Quickstart

Getting otsgo from Webinstall

curl -sS https://webi.sh/ots | sh

Getting otsgo from go install

$ go install github.com/emdneto/otsgo@latest

Getting otsgo from binary

You may download otsgo binary from the latest releases on Github.

Using otsgo CLI

Overview

$ ots -h
A simple CLI and API client for One-Time Secret

Usage:
  ots [flags]
  ots [command]

Available Commands:
  burn        Burn a secret that has not been read yet
  completion  generate the autocompletion script for the specified shell
  get         Get secret, metadata or recent
  help        Help about any command
  login       Perform basic http auth and store credentials
  share       Share or generate a random secret
  status      Current status of the system

Flags:
      --config string   config file (default is $HOME/.otsgo.yaml)
  -h, --help            help for ots
  -t, --toggle          Help message for toggle
  -v, --version         Displays current version

Use "ots [command] --help" for more information about a command.

Show OTS status

$ ots status

STATUS 	TIMESTAMP
nominal	1709507672

Share Secrets

$ ots share -h
Share or generate a random secret

Usage:
  ots share [flags]

Flags:
  -f, --from-stdin          Read from stdin
  -g, --generate            Generate a short, unique secret. This is useful for temporary passwords, one-time pads, salts, etc.
  -h, --help                help for share
  -p, --passphrase string   a string that the recipient must know to view the secret. This value is also used to encrypt the secret and is bcrypted before being stored so we only have this value in transit.
  -r, --recipient string    an email address. We will send a friendly email containing the secret link (NOT the secret itself).
  -s, --secret string       the secret value which is encrypted before being stored. There is a maximum length based on your plan that is enforced (1k-10k)
  -t, --ttl int             the maximum amount of time, in seconds, that the secret should survive (i.e. time-to-live). Once this time expires, the secret will be deleted and not recoverable. (default 604800)

Share a generated secret

$ ots share -g

Share custom secret with ttl and passphrase

$ ots share -s hellosecret -t 300 -p hello

Share secret from file

$ cat <<EOF | ots share -f -
secret: hello
seret: secret
EOF

$ echo "hellosecret" | ots share -f

Burn secrets

$ ots burn METADATA_KEY

Get secrets, metadata and recent

$ ots get -h
Get secret, metadata or recent

Usage:
  ots get [flags]
  ots get [command]

Available Commands:
  meta        Retrieve secret associated metadata
  recent      Retreive a list of recent metadata.
  secret      Retrieve a Secret

Get secret value

$ ots get secret SECRET_KEY

Get secret metadata

$ ots get meta METADATA_KEY

Get recent secrets (requires auth)

$ ots get recent

USER                    STATE           EXPIRES                 EXPIRED METADATA                        PASSHPHRASE     CREATED                 SENT    TTL       
anon                    viewed          2024-03-10 20:13:45     false   1z3bp2asyt2mo3xk0w4ddiveg0yhhor false           2024-03-03 20:13:45     []      167h58m13s
[email protected]  received        2024-03-10 20:01:40     false   drssrmf8avh5mv8mqlj2sgvi6tsqwz9 false           2024-03-03 20:01:40     []      0s        
[email protected]  received        2024-03-10 16:17:01     false   58aqvdaqwbh2b0gx1koru0baiid894a true            2024-03-03 16:17:01     []      0s        
[email protected]  received        2024-03-10 14:57:02     false   5s3onh5cyd2e1dsa5qmsm2afq91d3g0 false           2024-03-03 14:57:02     []      0s        
[email protected]  received        2024-03-10 14:55:23     false   n28eqt08te7gl7jphjg89b7p1s1cetk true            2024-03-03 14:55:23     []      0s        

Authentication

Auth with Environment Variables

otsgo will try to locate the credentials present in the environment variables. If found, every request will be made with HTTP Basic Authentication. If you get 404 Not authorized in any command, probably your credentials are wrong.

$ export OTS_USER=demo; export OTS_TOKEN=xyz
$ ots get recent
$ ots share -g -r [email protected]

Store auth credentials

Your password will be stored unencrypted in ~/.otsgo.yaml

$ ots login -u USERNAME -p API_TOKEN
$ ots get recent
$ ots share -g -r [email protected]

Common aliases

alias oss="ots share secret"
alias osgs="ots share secret -g"
alias ogs="ots get secret"
alias obs="ots burn secret"

otsgo's People

Contributors

dependabot[bot] avatar emdneto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

otsgo's Issues

ots get meta breaks with unknown secret

Behavior:

 ots get meta abcd
404 Unknown secret
unexpected end of JSON input
USER    STATE   EXPIRES                 EXPIRED METADATA        PASSHPHRASE     CREATED                 SENT    TTL
                1969-12-31 21:00:00     true                    false           1969-12-31 21:00:00     []      0s 

should handle this error to just output No secret found like in GetRecent.

Doesn't work on Linux CLI

ots --version
panic: Failed to initialize the X11 display, and the clipboard package
will not work properly. Install the following dependency may help:

	apt install -y libx11-dev

If the clipboard package is in an environment without a frame buffer,
such as a cloud server, it may also be necessary to install xvfb:

	apt install -y xvfb

and initialize a virtual frame buffer:

	Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
	export DISPLAY=:99.0

Then this package should be ready to use.


goroutine 1 [running]:
golang.design/x/clipboard.init.0()
	/go/pkg/mod/golang.design/x/[email protected]/clipboard_linux.go:65 +0x49

Keep local history of generated secrets

As I user I want to keep a local history of generated OTS. It should be available under the method ots get. If I'm authenticated it will use my credentials to retrieve recent secrets. If I'm not authenticated, it will read the local history.

Support burning secrets with passphrase

I am trying to burn a secret with the CLI but I get a 404 unknown secret (despite the fact that I get the METADATA_KEY from ots get recent.

$ ots burn METADATA_KEY

https://onetimesecret.com/api/v1/private/METADATA_KEY/burn
404 Unknown secret

While going on the WebUI of OneTimeSecret, I saw: "provide the passphrase of the secret"

According to the API Doc:

Burn a secret
POST https://onetimesecret.com/api/v1/private/METADATA_KEY/burn
Burn a secret that has not been read yet.

Query Params
* None

Attributes
* Same as metadata attributes with a status of burned.

Example:
$ curl -X POST -u 'USERNAME:APITOKEN' https://onetimesecret.com/api/v1/private/METADATA_KEY/burn

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.