config
Code
Branches
CI
Releases
Discussions
Prompts
Insights
Settings
base / internal / config / home.go
Download this file
1 package config 2 3 import ( 4 "errors" 5 6 "amadan.net/oficina/home/connect" 7 ) 8 9 // LoadHome decodes the Oficina ID settings, which connect.CredentialsFromEnv 10 // reads: BASE_HOME_ISSUER, BASE_HOME_CONSUMER_ID, BASE_HOME_KEYS_BASE64, 11 // BASE_HOME_DEK_BASE64 and, optionally, HOME_DIRECTORY_ORIGIN. All four 12 // empty (creds nil) leaves Oficina ID off and returns nil. Some but not all, 13 // or any that do not decode, is an error, so Base never falls back to its own 14 // sign-in by accident. The error never carries a value. 15 func LoadHome(creds *connect.Credentials, origin string) (*connect.DecodedCredentials, error) { 16 home, err := connect.DecodeCredentials(creds, origin) 17 if err != nil { 18 return nil, errors.New("BASE_HOME_ISSUER, BASE_HOME_CONSUMER_ID, BASE_HOME_KEYS_BASE64 and BASE_HOME_DEK_BASE64 turn on Oficina ID sign-in: set all four to valid values, or none (BASE_ORIGIN must be https, and HOME_DIRECTORY_ORIGIN, if set, a bare https origin)") 19 } 20 return home, nil 21 } 22