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 ¶
const ( 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.
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. **値は持たない。**