Skip to content

Commit

Permalink
api: create AuthDialer and ProtocolDialer
Browse files Browse the repository at this point in the history
To disable SSL by default we want to transfer
`OpenSslDialer` to the go-openssl repository.
In order to do so, we need to minimize the amount of
copy-paste of the private functions.

`AuthDialer` is created as a dialer-wrapper, that
calls authentication methods.
`ProtoDialer` is created to check the `ProtocolInfo`
in the created connection.

`NoAuth` constant is added for dialers, that do not
require authentication

Part of #301
  • Loading branch information
DerekBum committed Jan 30, 2024
1 parent 6ba01ff commit 7038359
Show file tree
Hide file tree
Showing 7 changed files with 417 additions and 77 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
the response (#237)
- Ability to mock connections for tests (#237). Added new types `MockDoer`,
`MockRequest` to `test_helpers`.
- `AuthDialer` and `ProtocolDialer` types for creating a dialer with
authentication and `ProtocolInfo` check (#301)
- `NoAuth` constant for dialers that do not require authentication (#301)

### Changed

Expand Down
5 changes: 5 additions & 0 deletions auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ const (
// available only for the Tarantool Enterprise Edition (EE) with
// SSL transport.
PapSha256Auth

// NoAuth is used when no authentication is needed.
NoAuth Auth = 1 << 15
)

// String returns a string representation of an authentication method.
Expand All @@ -38,6 +41,8 @@ func (a Auth) String() string {
return chapSha1
case PapSha256Auth:
return papSha256
case NoAuth:
return "no-auth"
default:
return fmt.Sprintf("unknown auth type (code %d)", a)
}
Expand Down
1 change: 1 addition & 0 deletions auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestAuth_String(t *testing.T) {
{AutoAuth, "auto"},
{ChapSha1Auth, "chap-sha1"},
{PapSha256Auth, "pap-sha256"},
{NoAuth, "no-auth"},
{Auth(unknownId), fmt.Sprintf("unknown auth type (code %d)", unknownId)},
}

Expand Down
4 changes: 3 additions & 1 deletion connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,9 @@ func (conn *Connection) dial(ctx context.Context) error {
}

conn.addr = c.Addr()
conn.Greeting.Version = c.Greeting().Version
connGreeting := c.Greeting()
conn.Greeting.Version = connGreeting.Version
conn.Greeting.Salt = connGreeting.Salt
conn.serverProtocolInfo = c.ProtocolInfo()

spaceAndIndexNamesSupported :=
Expand Down
Loading

0 comments on commit 7038359

Please sign in to comment.