onepassword

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 25 Imported by: 0

README

POSH 1Password provider

Integrates 1Password into your shell and adds helpers for your commands.

Help

1Password session helper.

Usage:
  op [command]

Available commands:
  get [id]          Retrieve an entry from your account
  signin            Sign into your 1Password account for the session
  register [email]  Add your 1Password account

Usage

Plugin
package plugin

type Plugin struct {
  l        log.Logger
  oo       *onepassword.OnePassword
  cacche   cache.Cache
  commands command.Commands
}

func New(l log.Logger) (plugin.Plugin, error) {
  inst := &Plugin{
    l:        l,
    cache:    cache.MemoryCache{},
    commands: command.Commands{},
  }

  // ...

  inst.op, err := onepassword.New(l, inst.cache));
  if err != nil {
    return nil, errors.Wrap(err, "failed to create onepassword")
  }

  // ...

  inst.commands.MustAdd(onepassword.NewCommand(l, onePassword))

  // ...

  return inst, nil
}
Config

Add this to your '.posh.yml' file:

onePassword:
  account: <ACCOUNT>
  tokenFilename: .posh/config/.op

To add a requirement check for op, add:

require:
  scripts:
    - name: op
      command: |
        [[ $(op account --account <ACCOUNT> get 2>&1) =~ "found no account" ]] && exit 1 || exit 0
      help: |
        You're 1Password account is not registered yet! Please do so by running:

          $ op account add --address <ACCOUNT>.1password.eu --email <EMAIL>
  packages:
    - name: op
      version: '~2'
      command: op --version
      help: |
        Please ensure you have the 1Password cli 'op' installed in the required version: %s!

          $ brew update
          $ brew install 1password-cli

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotSignedIn = errors.New("you're not signed into your 1password account")

Functions

func AuthChecker added in v0.3.0

func AuthChecker(p *OnePassword) check.Checker

Types

type Command

type Command struct {
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(l log.Logger, op *OnePassword, opts ...CommandOption) (*Command, error)

func (*Command) Complete

func (c *Command) Complete(ctx context.Context, r *readline.Readline) []goprompt.Suggest

func (*Command) Description

func (c *Command) Description() string

func (*Command) Execute

func (c *Command) Execute(ctx context.Context, r *readline.Readline) error

func (*Command) Help

func (c *Command) Help(ctx context.Context, r *readline.Readline) string

func (*Command) Name

func (c *Command) Name() string

type CommandOption

type CommandOption func(*Command) error

func CommandWithName added in v0.3.3

func CommandWithName(v string) CommandOption

type Config

type Config struct {
	Account       string `json:"account" yaml:"account"`
	TokenFilename string `json:"tokenFilename" yaml:"tokenFilename"`
}

type OnePassword

type OnePassword struct {
	// contains filtered or unexported fields
}

func New

func New(l log.Logger, cache cache.Cache, opts ...Option) (*OnePassword, error)

func (*OnePassword) Get

func (op *OnePassword) Get(ctx context.Context, secret Secret) (string, error)

func (*OnePassword) GetDocument added in v0.1.0

func (op *OnePassword) GetDocument(ctx context.Context, secret Secret) (string, error)

func (*OnePassword) GetOnetimePassword

func (op *OnePassword) GetOnetimePassword(ctx context.Context, account, uuid string) (string, error)

func (*OnePassword) IsAuthenticated added in v0.3.0

func (op *OnePassword) IsAuthenticated(ctx context.Context) (bool, error)

func (*OnePassword) Render

func (op *OnePassword) Render(ctx context.Context, source string) ([]byte, error)

func (*OnePassword) RenderFile

func (op *OnePassword) RenderFile(ctx context.Context, source string) ([]byte, error)

func (*OnePassword) RenderFileTo

func (op *OnePassword) RenderFileTo(ctx context.Context, source, target string) error

func (*OnePassword) SignIn

func (op *OnePassword) SignIn(ctx context.Context) error

type Option

type Option func(*OnePassword) error

func WithConfigKey

func WithConfigKey(v string) Option

type Secret

type Secret struct {
	Account string `json:"account" yaml:"account"`
	Vault   string `json:"vault" yaml:"vault"`
	Item    string `json:"item" yaml:"item"`
	Field   string `json:"field" yaml:"field"`
}

Jump to

Keyboard shortcuts

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