auth

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package auth manages credentials stored on disk.

Credentials are persisted as multiple KEY=VALUE entries in a single file at the path returned by config.CredentialsPath() (~/.config/jungi/credentials), with file permissions 0600 so that only the owning user can read it. No environment variables are read or written.

Index

Constants

This section is empty.

Variables

View Source
var Registry = []Descriptor{
	{
		Key:         "OPENROUTER_API_KEY",
		Label:       "OpenRouter API Key",
		Description: "API key used to authenticate with the OpenRouter API.",
	},
	{
		Key:         "JUNGI_CONTROL_API_KEY",
		Label:       "Jungi Control API Key",
		Description: "API key used to authenticate with the jungi control service.",
	},
}

Registry lists every credential /credentials can set. It is the single source of truth the picker iterates; register additional credentials here to make them selectable.

Functions

func APIKeyForProvider added in v0.2.0

func APIKeyForProvider() string

APIKeyForProvider returns the stored OpenRouter API key, or an empty string if none has been set. A missing key surfaces as an auth error on the first API call rather than falling back to anything else.

func All

func All() (map[string]string, error)

All returns every stored credential as a map. It returns an empty map and a nil error when the file does not exist.

func Delete

func Delete(key string) error

Delete removes a single key from the credentials file, preserving all other entries. It is idempotent: deleting an absent key or a missing file is not an error.

func Get

func Get(key string) (string, error)

Get returns the value stored for key. It returns an empty string and a nil error when the file or the key is absent; all other I/O errors are propagated.

func JungiControlAPIKey

func JungiControlAPIKey() (string, error)

JungiControlAPIKey returns the stored jungi control API key, or an empty string if none has been set.

func OpenRouterAPIKey added in v0.2.0

func OpenRouterAPIKey() (string, error)

OpenRouterAPIKey returns the stored OpenRouter API key, or an empty string if none has been set.

func Set

func Set(key, value string) error

Set upserts key=value into the credentials file, preserving all other entries.

Types

type Descriptor

type Descriptor struct {
	// Key is the KEY=VALUE store key, e.g. "ANTHROPIC_API_KEY".
	Key string
	// Label is the human-readable name shown in the picker.
	Label string
	// Description gives additional context shown alongside the label.
	Description string
}

Descriptor describes a single credential the /credentials picker can offer.

Source Files

  • auth.go

Jump to

Keyboard shortcuts

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