25 lines
555 B
Go
25 lines
555 B
Go
// Package oauth provides OAuth utilities for generating and checking secure state tokens
|
|
package oauth
|
|
|
|
import (
|
|
"git.haelnorr.com/h/golib/env"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
type Config struct {
|
|
PrivateKey string `ezconf:"OAUTH_PRIVATE_KEY,required,description:Private key for signing OAuth state tokens"`
|
|
}
|
|
|
|
func ConfigFromEnv() (any, error) {
|
|
cfg := &Config{
|
|
PrivateKey: env.String("OAUTH_PRIVATE_KEY", ""),
|
|
}
|
|
|
|
// Check required fields
|
|
if cfg.PrivateKey == "" {
|
|
return nil, errors.New("Envar not set: OAUTH_PRIVATE_KEY")
|
|
}
|
|
|
|
return cfg, nil
|
|
}
|