package config import ( "errors" "amadan.net/oficina/home/connect" ) // LoadHome decodes the Oficina ID settings, which connect.CredentialsFromEnv // reads: BASE_HOME_ISSUER, BASE_HOME_CONSUMER_ID, BASE_HOME_KEYS_BASE64, // BASE_HOME_DEK_BASE64 and, optionally, HOME_DIRECTORY_ORIGIN. All four // empty (creds nil) leaves Oficina ID off and returns nil. Some but not all, // or any that do not decode, is an error, so Base never falls back to its own // sign-in by accident. The error never carries a value. func LoadHome(creds *connect.Credentials, origin string) (*connect.DecodedCredentials, error) { home, err := connect.DecodeCredentials(creds, origin) if err != nil { 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)") } return home, nil }