Documentation
¶
Overview ¶
Package profile manages named, reusable sets of ndx CLI flag defaults (identity provider issuer, client ID, scopes, callback port, Portal Backend URL, TLS verification) cached at ~/.openndx/config.json. Profiles let an operator switch between environments (local dev, staging, a partner's deployment) without retyping every flag on every command; any flag passed explicitly on the command line still overrides the active profile.
Index ¶
Constants ¶
const ( ThunderIDCLIClientID = "NDX_CLI" ThunderIDCallbackPort = 8765 )
ThunderIDCLIClientID and ThunderIDCallbackPort are the ndx CLI's OAuth2 client ID and redirect callback port as registered with this repo's local ThunderID instance (thunderid/bootstrap/application.yaml). ThunderID rejects any redirect URI other than the exact one registered there (http://127.0.0.1:8765/callback) - a wildcard/wrong port fails login - so `ondx login` must reject any other --callback-port when logging in as this client, rather than silently trying (and failing) against ThunderID.
const DefaultName = "local"
DefaultName is the profile ondx falls back to when no config file exists yet and none is named explicitly, pre-populated with this repo's docker-compose local-dev stack (ThunderID as IDP, Portal Backend on :8083) so `ondx login` works with zero flags out of the box.
const LocalPBResource = "http://pb.openndx.local"
LocalPBResource is the Portal Backend resource server identifier registered with this repo's local ThunderID (thunderid/bootstrap/resource.yaml). ThunderID sets an access token's `aud` to the resource requested at login, and Portal Backend only accepts tokens for this audience.
Variables ¶
This section is empty.
Functions ¶
func DefaultConfigPath ¶
DefaultConfigPath returns the default location for the profile config file.
Types ¶
type Config ¶
type Config struct {
CurrentProfile string `json:"current_profile"`
Profiles map[string]Profile `json:"profiles"`
}
Config is the on-disk shape of ~/.openndx/config.json.
func Load ¶
Load reads the config file at path. A missing file is not an error - it yields a config with just the built-in default profile, so a first-time user gets working defaults without ever running `ondx profile set`. The default profile is likewise injected whenever the file exists but doesn't define one of its own under DefaultName.
type Profile ¶
type Profile struct {
Issuer string `json:"issuer,omitempty"`
AuthURL string `json:"auth_url,omitempty"`
TokenURL string `json:"token_url,omitempty"`
ClientID string `json:"client_id,omitempty"`
Scopes string `json:"scopes,omitempty"`
CallbackPort int `json:"callback_port,omitempty"`
// Resource is sent as `resource=` at login, so the identity provider
// issues the token for Portal Backend's audience.
Resource string `json:"resource,omitempty"`
PBURL string `json:"pb_url,omitempty"`
Insecure bool `json:"insecure,omitempty"`
}
Profile is one named set of flag defaults. Every field is optional - callers use it purely to seed a flag's default value, so a zero value simply falls through to whatever the caller does when a flag is unset.