pluginsecrets

package
v0.0.0-...-9914b64 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package pluginsecrets serves the control-panel endpoints for server plugins' secret values (#3470).

各プラグインの名前空間の予約パスに生える。

POST /api/plugin/<name>/_secrets         一覧 (値は返さない)
POST /api/plugin/<name>/_secrets/set     保存
POST /api/plugin/<name>/_secrets/delete  削除

**権限の確認は配線側 (internal/server) の middleware が行う。** 管理者で、 かつブラウザでログインした token (users.token) で呼ばれたものだけがここに 届く。ここでは確認しない — 二重に書くと、片方を外しても気付けない。

値を返さない

どの応答にも値そのものは入れない。「設定済みか」「今の鍵で読めるか」と、 十分に長い値の末尾 4 文字だけを返す。管理画面を覗かれただけで漏れる形にしない。

Index

Constants

View Source
const (
	CodeUnavailable        = "SECRETS_UNAVAILABLE"
	CodeUnknownSecret      = "UNKNOWN_SECRET"
	CodeInvalidSecretParam = "INVALID_SECRET_PARAM"
)

Error codes. プラグインのルートと同じ `{"error": {"message", "code"}}` の形で返す。

本家の apierr (code + id) には載せない。プラグインの名前空間にある Elythia 独自の口なので、本家の `INVALID_PARAM` と名前を分けて取り違えを防ぐ。

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler serves one plugin's secret endpoints.

func New

func New(svc *pluginsecret.Service, pluginName string, declared []plugin.SecretSpec) *Handler

New builds the handler for one plugin.

func (*Handler) Delete

func (h *Handler) Delete(c *echo.Context) error

Delete removes a secret, declared or not.

func (*Handler) List

func (h *Handler) List(c *echo.Context) error

List returns the declared and stored secrets without their values.

func (*Handler) Set

func (h *Handler) Set(c *echo.Context) error

Set stores a declared secret. 204 を返し、値も末尾も返さない。

type ListResponse

type ListResponse struct {
	// Available is false when pluginSecretKey is not configured. そのときは
	// 保存も削除もできない。
	Available bool         `json:"available"`
	Secrets   []SecretInfo `json:"secrets"`
}

ListResponse is the body of POST /api/plugin/<name>/_secrets.

type SecretInfo

type SecretInfo struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	// Declared reports whether the plugin declares this secret in
	// Definition.Secrets. 宣言されていない値 (プラグインが実行時に自分で
	// 置いたもの) は、管理画面からは消せるが入れられない。
	Declared   bool `json:"declared"`
	Configured bool `json:"configured"`
	// Readable is false when the stored value does not decrypt with the
	// current key (the key was replaced or lost).
	Readable bool `json:"readable"`
	// Hint is the last 4 characters of a value at least 20 characters long.
	Hint      *string `json:"hint"`
	UpdatedAt *string `json:"updatedAt"`
}

SecretInfo is one row of the list response. **値は持たない。**

Jump to

Keyboard shortcuts

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