Repository: snowflakedb/gosnowflake
Pull request #1216 (2024-10-08 08:05:11)

SNOW-1692674 Remove *.okta.com check from native Okta authenticator validation
### Description

SNOW-XXX Please explain the changes you made here.

### Checklist
- [ ] Created tests which fail without the change (if possible)
- [ ] Extended the README / documentation, if necessary


codecov[bot]: ## [Codecov](https://app.codecov.io/gh/snowflakedb/gosnowflake/pull/1216?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb) Report
All modified and coverable lines are covered by tests :white_check_mark:
> Project coverage is 82.60%. Comparing base [(`1197e55`)](https://app.codecov.io/gh/snowflakedb/gosnowflake/commit/1197e558b48b305a6c11250b0b46e70e036f1e45?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb) to head [(`b486501`)](https://app.codecov.io/gh/snowflakedb/gosnowflake/commit/b4865012ec73353473cd68393fa0adfad1598cfd?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb).

<details><summary>Additional details and impacted files</summary>


```diff
@@           Coverage Diff           @@
##           master    #1216   +/-   ##
=======================================
  Coverage   82.60%   82.60%           
=======================================
  Files          54       54           
  Lines       12909    12909           
=======================================
  Hits        10663    10663           
  Misses       2246     2246           
```

</details>

[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/snowflakedb/gosnowflake/pull/1216?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb).   
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=snowflakedb).


Patch:
diff --git a/auth.go b/auth.go
index 1ada05f..3839e78 100644
--- a/auth.go
+++ b/auth.go
@@ -93,7 +93,7 @@ func determineAuthenticatorType(cfg *Config, value string) error {
 			}
 		}
 
-		if oktaURL.Scheme != "https" || !strings.HasSuffix(oktaURL.Host, "okta.com") {
+		if oktaURL.Scheme != "https" {
 			return &SnowflakeError{
 				Number:      ErrCodeFailedToParseAuthenticator,
 				Message:     errMsgFailedToParseAuthenticator,


Test patch:
diff --git a/dsn_test.go b/dsn_test.go
index a7f9103..d439556 100644
--- a/dsn_test.go
+++ b/dsn_test.go
@@ -645,6 +645,28 @@ func TestParseDSN(t *testing.T) {
 			ocspMode: ocspModeFailOpen,
 			err:      nil,
 		},
+		{
+			dsn: fmt.Sprintf("u:p@ac.snowflake.local:9876?account=ac&protocol=http&authenticator=%v", url.QueryEscape("https://ac.some-host.com/custom-okta-url")),
+			config: &Config{
+				Account: "ac", User: "u", Password: "p",
+				Authenticator: AuthTypeOkta,
+				OktaURL: &url.URL{
+					Scheme: "https",
+					Host:   "ac.some-host.com",
+					Path:   "/custom-okta-url",
+				},
+				PrivateKey: testPrivKey,
+				Protocol:   "http", Host: "ac.snowflake.local", Port: 9876,
+				OCSPFailOpen:              OCSPFailOpenTrue,
+				ValidateDefaultParameters: ConfigBoolTrue,
+				ClientTimeout:             defaultClientTimeout,
+				JWTClientTimeout:          defaultJWTClientTimeout,
+				ExternalBrowserTimeout:    defaultExternalBrowserTimeout,
+				IncludeRetryReason:        ConfigBoolTrue,
+			},
+			ocspMode: ocspModeFailOpen,
+			err:      nil,
+		},
 		{
 			dsn: fmt.Sprintf("u:p@a.snowflake.local:9876?account=a&protocol=http&authenticator=SNOWFLAKE_JWT&privateKey=%v", privKeyPKCS1),
 			config: &Config{