Skip to content

Commit

Permalink
change disableConsoleLogin optional in the DSN
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-ext-simba-jl committed Jan 15, 2024
1 parent 8e1ae8e commit 76551a5
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 104 deletions.
4 changes: 4 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,10 @@ func authenticateWithConfig(sc *snowflakeConn) error {
if sc.cfg.ClientStoreTemporaryCredential == ConfigBoolTrue {
fillCachedIDToken(sc)
}
// Disable console login by default
if sc.cfg.DisableConsoleLogin == configBoolNotSet {
sc.cfg.DisableConsoleLogin = ConfigBoolTrue
}
}

if sc.cfg.Authenticator == AuthTypeUsernamePasswordMFA {
Expand Down
6 changes: 3 additions & 3 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -694,12 +694,12 @@ func TestUnitAuthenticateWithConfigExternalBrowser(t *testing.T) {
}
sc := getDefaultSnowflakeConn()
sc.cfg.Authenticator = AuthTypeExternalBrowser
sc.cfg.ExternalBrowserTimeout = defaultExternalBrowserTimeout
sc.rest = sr
sc.ctx = context.Background()
err = authenticateWithConfig(sc)
if err == nil {
t.Fatalf("should have failed.")
}
assertNotNilF(t, err, "should have failed at FuncPostAuthSAML.")
assertEqualE(t, err.Error(), "failed to get SAML response")
}

func TestUnitAuthenticateExternalBrowser(t *testing.T) {
Expand Down
6 changes: 1 addition & 5 deletions authexternalbrowser.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,7 @@ func getIdpURLProofKey(
}

// Gets the login URL for multiple SAML
func getLoginURL(
sr *snowflakeRestful,
user string,
callbackPort int) (string, string, error) {

func getLoginURL(sr *snowflakeRestful, user string, callbackPort int) (string, string, error) {
proofKey := generateProofKey()

params := &url.Values{}
Expand Down
10 changes: 0 additions & 10 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ The following connection parameters are supported:
- clientConfigFile: specifies the location of the client configuration json file.
In this file you can configure Easy Logging feature.
- disableConsoleLogin: true by default. Set to false to enable the console login. Should be used in
conjunction with the "externalbrowser" authenticator.
All other parameters are interpreted as session parameters (https://docs.snowflake.com/en/sql-reference/parameters.html).
For example, the TIMESTAMP_OUTPUT_FORMAT session parameter can be set by adding:
Expand Down Expand Up @@ -687,13 +684,6 @@ or using a Config structure with following ExternalBrowserTimeout specified:
ExternalBrowserTimeout: 240 * time.Second, // Requires time.Duration
}
If multiple SAML2 integrations are present for the account, users are required to login via the console by setting
DSN field "disableConsoleLogin=false" or using a Config structure with following DisableConsoleLogin specified:
config := &Config{
DisableConsoleLogin: ConfigBoolFalse, // Requires ConfigBool
}
# Executing Multiple Statements in One Call
This feature is available in version 1.3.8 or later of the driver.
Expand Down
4 changes: 0 additions & 4 deletions dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,6 @@ func fillMissingConfigParameters(cfg *Config) error {
cfg.IncludeRetryReason = ConfigBoolTrue
}

if cfg.DisableConsoleLogin == configBoolNotSet {
cfg.DisableConsoleLogin = ConfigBoolTrue
}

if strings.HasSuffix(cfg.Host, defaultDomain) && len(cfg.Host) == len(defaultDomain) {
return &SnowflakeError{
Number: ErrCodeFailedToParseHost,
Expand Down
Loading

0 comments on commit 76551a5

Please sign in to comment.