Secrets Management

Table of Contents

Secrets Management

(setq auth-sources '("~/.authinfo"))
(auth-source-forget-all-cached)

(defun get-env-var (name)
  "Safely get the value of an environment variable."
  (let ((value (getenv name)))
    (if value
        value
      (message "Environment variable %s not set" name)
      nil)))

(defun get-password (key)
  "Retrieve a password from the Unix password manager 'pass'."
  (let ((password (shell-command-to-string (concat "pass " key))))
    (if (string-match-p "^gpg:" password)
        (progn
          (message "Failed to retrieve password for %s" key)
          nil)
      (string-trim password))))

(use-package ghub)

(with-eval-after-load 'tramp
  (ghub-request "GET" "/user" nil
                :forge 'github
                :host "api.github.com"
                :username "jwalsh"
                :auth 'forge))

Author: Jason Walsh

jwalsh@nexus

Last Updated: 2025-07-30 13:45:27

build: 2025-12-23 09:13 | sha: e32f33e