Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup rtcd URL from credentials #81

Merged
merged 1 commit into from
May 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions server/rtcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,12 @@ func (m *rtcdClientManager) getRTCDClientConfig(rtcdURL string, dialFn rtcd.Dial
// Give precedence to environment to override everything else.
cfg.ClientID = os.Getenv("MM_CLOUD_INSTALLATION_ID")
if cfg.ClientID == "" {
if isCloud(m.ctx.pluginAPI.System.GetLicense()) {
m.ctx.LogError("installation id is missing")
}
cfg.ClientID = os.Getenv("CALLS_RTCD_CLIENT_ID")
} else {
m.ctx.LogDebug("installation id is set", "id", cfg.ClientID)
}
cfg.AuthKey = os.Getenv("CALLS_RTCD_AUTH_KEY")
cfg.URL = rtcdURL
Expand All @@ -398,15 +403,16 @@ func (m *rtcdClientManager) getRTCDClientConfig(rtcdURL string, dialFn rtcd.Dial
}

// Parsing the URL in case it's already containing credentials.
u, clientID, authKey, err := parseURL(cfg.URL)
if err != nil {
return cfg, fmt.Errorf("failed to parse URL: %w", err)
}
if cfg.ClientID == "" && cfg.AuthKey == "" {
u, clientID, authKey, err := parseURL(cfg.URL)
if err != nil {
return cfg, fmt.Errorf("failed to parse URL: %w", err)
}
cfg.ClientID = clientID
cfg.AuthKey = authKey
cfg.URL = u
}
// Updating to the clean URL (with credentials stripped if present).
cfg.URL = u

// if no URL has been provided until now we fail with error.
if cfg.URL == "" {
Expand Down