Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
StackExchange.Redis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
StackExchange.Redis
Commits
84bce912
Unverified
Commit
84bce912
authored
Mar 30, 2020
by
Marc Gravell
Committed by
GitHub
Mar 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow auth with user (redis 6) (#1410)
parent
8349c04f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
+24
-3
ConfigurationOptions.cs
src/StackExchange.Redis/ConfigurationOptions.cs
+14
-1
ServerEndPoint.cs
src/StackExchange.Redis/ServerEndPoint.cs
+10
-2
No files found.
src/StackExchange.Redis/ConfigurationOptions.cs
View file @
84bce912
...
...
@@ -76,6 +76,7 @@ internal const string
HighPrioritySocketThreads
=
"highPriorityThreads"
,
KeepAlive
=
"keepAlive"
,
ClientName
=
"name"
,
User
=
"user"
,
Password
=
"password"
,
PreserveAsyncOrder
=
"preserveAsyncOrder"
,
Proxy
=
"proxy"
,
...
...
@@ -104,6 +105,7 @@ internal const string
DefaultDatabase
,
HighPrioritySocketThreads
,
KeepAlive
,
User
,
Password
,
PreserveAsyncOrder
,
Proxy
,
...
...
@@ -305,6 +307,11 @@ public int ConnectTimeout
public
int
KeepAlive
{
get
{
return
keepAlive
.
GetValueOrDefault
(-
1
);
}
set
{
keepAlive
=
value
;
}
}
#pragma warning restore RCS1128 // Use coalesce expression.
/// <summary>
/// The user to use to authenticate with the server.
/// </summary>
public
string
User
{
get
;
set
;
}
/// <summary>
/// The password to use to authenticate with the server.
/// </summary>
...
...
@@ -441,6 +448,7 @@ public ConfigurationOptions Clone()
allowAdmin
=
allowAdmin
,
defaultVersion
=
defaultVersion
,
connectTimeout
=
connectTimeout
,
User
=
User
,
Password
=
Password
,
tieBreaker
=
tieBreaker
,
writeBuffer
=
writeBuffer
,
...
...
@@ -505,6 +513,7 @@ public string ToString(bool includePassword)
Append
(
sb
,
OptionKeys
.
AllowAdmin
,
allowAdmin
);
Append
(
sb
,
OptionKeys
.
Version
,
defaultVersion
);
Append
(
sb
,
OptionKeys
.
ConnectTimeout
,
connectTimeout
);
Append
(
sb
,
OptionKeys
.
User
,
User
);
Append
(
sb
,
OptionKeys
.
Password
,
(
includePassword
||
string
.
IsNullOrEmpty
(
Password
))
?
Password
:
"*****"
);
Append
(
sb
,
OptionKeys
.
TieBreaker
,
tieBreaker
);
Append
(
sb
,
OptionKeys
.
WriteBuffer
,
writeBuffer
);
...
...
@@ -597,9 +606,10 @@ private static void Append(StringBuilder sb, string prefix, object value)
private
void
Clear
()
{
ClientName
=
ServiceName
=
Password
=
tieBreaker
=
sslHost
=
configChannel
=
null
;
ClientName
=
ServiceName
=
User
=
Password
=
tieBreaker
=
sslHost
=
configChannel
=
null
;
keepAlive
=
syncTimeout
=
asyncTimeout
=
connectTimeout
=
writeBuffer
=
connectRetry
=
configCheckSeconds
=
DefaultDatabase
=
null
;
allowAdmin
=
abortOnConnectFail
=
highPrioritySocketThreads
=
resolveDns
=
ssl
=
null
;
SslProtocols
=
null
;
defaultVersion
=
null
;
EndPoints
.
Clear
();
commandMap
=
null
;
...
...
@@ -686,6 +696,9 @@ private void DoParse(string configuration, bool ignoreUnknown)
case
OptionKeys
.
Version
:
DefaultVersion
=
OptionKeys
.
ParseVersion
(
key
,
value
);
break
;
case
OptionKeys
.
User
:
User
=
value
;
break
;
case
OptionKeys
.
Password
:
Password
=
value
;
break
;
...
...
src/StackExchange.Redis/ServerEndPoint.cs
View file @
84bce912
...
...
@@ -753,8 +753,16 @@ private async Task HandshakeAsync(PhysicalConnection connection, LogProxy log)
return
;
}
Message
msg
;
string
password
=
Multiplexer
.
RawConfig
.
Password
;
if
(!
string
.
IsNullOrWhiteSpace
(
password
))
// note that we need "" (not null) for password in the case of 'nopass' logins
string
user
=
Multiplexer
.
RawConfig
.
User
,
password
=
Multiplexer
.
RawConfig
.
Password
??
""
;
if
(!
string
.
IsNullOrWhiteSpace
(
user
))
{
log
?.
WriteLine
(
"Authenticating (user/password)"
);
msg
=
Message
.
Create
(-
1
,
CommandFlags
.
FireAndForget
,
RedisCommand
.
AUTH
,
(
RedisValue
)
user
,
(
RedisValue
)
password
);
msg
.
SetInternalCall
();
await
WriteDirectOrQueueFireAndForgetAsync
(
connection
,
msg
,
ResultProcessor
.
DemandOK
).
ForAwait
();
}
else
if
(!
string
.
IsNullOrWhiteSpace
(
password
))
{
log
?.
WriteLine
(
"Authenticating (password)"
);
msg
=
Message
.
Create
(-
1
,
CommandFlags
.
FireAndForget
,
RedisCommand
.
AUTH
,
(
RedisValue
)
password
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment