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

SNOW-1373131 disable connection pooling for external browser authentication #941

Conversation

sfc-gh-dstempniak
Copy link
Collaborator

Description

Disable connection pooling for external browser authentication.

Checklist

  • Code compiles correctly
  • Code is formatted according to Coding Conventions
  • Created tests which fail without the change (if possible)
  • All tests passing (dotnet test)
  • Extended the README / documentation, if necessary
  • Provide JIRA issue id (if possible) or GitHub issue id in PR name

sfc-gh-mhofman and others added 26 commits April 29, 2024 12:54
…some of its settings gets changed and no longer match the pool initial setup
… session interface SnowflakeDbSessionPool, removal of pool config setters
…-changed-session-behavior

# Conflicts:
#	Snowflake.Data/Core/Session/SessionPool.cs
…turned by the server in case of values \"final\"
@sfc-gh-dstempniak sfc-gh-dstempniak requested a review from a team as a code owner May 13, 2024 08:08
+ ";authenticator=externalbrowser;[email protected];POOLINGENABLED=TRUE";
conn.Open();
Assert.AreEqual(ConnectionState.Open, conn.State);
Assert.AreEqual(true, SnowflakeDbConnectionPool.GetPool(conn.ConnectionString).GetPooling());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why true? the feature was about enforcing it to be false?

{ SFSessionProperty.CHANGEDSESSION, DefaultValue(SFSessionProperty.CHANGEDSESSION) },
{ SFSessionProperty.WAITINGFORIDLESESSIONTIMEOUT, DefaultValue(SFSessionProperty.WAITINGFORIDLESESSIONTIMEOUT) },
{ SFSessionProperty.EXPIRATIONTIMEOUT, DefaultValue(SFSessionProperty.EXPIRATIONTIMEOUT) },
{ SFSessionProperty.POOLINGENABLED, "true" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why true?

{ SFSessionProperty.POOLINGENABLED, "false" } // by default pooling is disabled for externalbrowser authentication
}
};
var testCaseWithExternalBrowserAndPoolingEnabled = new TestCase()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it works, and we have some tests written in this manner, but I would prefer the way of writing test like TestValidateCorrectAccountNames() - so a dedicated test verifying only the properties which are important from given test point of view.

@@ -296,6 +296,19 @@ private static void ValidateAuthenticator(SFSessionProperties properties)
logger.Error(error);
throw new SnowflakeDbException(SFError.UNKNOWN_AUTHENTICATOR, authenticator);
}

if (authenticator.Equals(ExternalBrowserAuthenticator.AUTH_NAME))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this logic would fit better to SFSessionHttpClientProperties class.
In SFSessionHttpClientProperties we interpret string values as proper types values and we do a logic of changing the values.
SFSessionProperty is operates only on string values rather without interpreting them.


if (authenticator.Equals(ExternalBrowserAuthenticator.AUTH_NAME))
{
if (!properties.TryGetValue(SFSessionProperty.POOLINGENABLED, out var poolingEnabledStr))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should all this logic be for old pool as well?

}
else if (Boolean.TryParse(poolingEnabledStr, out var poolingEnabled) && poolingEnabled)
{
logger.Warn("Connection pooling is enabled for external browser authentication");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should enforce false for the new pool I belive

Base automatically changed from pool/SNOW-937188-changed-session-behavior to pool/SNOW-860872-connection-pool May 13, 2024 13:20
@sfc-gh-dstempniak sfc-gh-dstempniak changed the base branch from pool/SNOW-860872-connection-pool to master May 13, 2024 13:37
Copy link

gitguardian bot commented May 13, 2024

️✅ There are no secrets present in this pull request anymore.

If these secrets were true positive and are still valid, we highly recommend you to revoke them.
Once a secret has been leaked into a git repository, you should consider it compromised, even if it was deleted immediately.
Find here more information about risks.


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@sfc-gh-dstempniak sfc-gh-dstempniak changed the base branch from master to pool/SNOW-860872-connection-pool May 13, 2024 13:48
@sfc-gh-knozderko sfc-gh-knozderko force-pushed the pool/SNOW-860872-connection-pool branch from 49d5d13 to 97cceaf Compare May 14, 2024 10:32
@sfc-gh-dstempniak sfc-gh-dstempniak deleted the pool/SNOW-1373131_external_browser branch May 14, 2024 11:50
@github-actions github-actions bot locked and limited conversation to collaborators May 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants