Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
B
brpc
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
brpc
Commits
bbced206
Commit
bbced206
authored
Nov 16, 2017
by
wuchengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change auth response failure and destroy auth response msg and code style
parent
afbee1f0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
23 deletions
+19
-23
client.cpp
example/couchbase_c++/client.cpp
+0
-0
memcache.h
src/brpc/memcache.h
+0
-6
couchbase_authenticator.cpp
src/brpc/policy/couchbase_authenticator.cpp
+15
-16
memcache_binary_protocol.cpp
src/brpc/policy/memcache_binary_protocol.cpp
+4
-1
No files found.
example/couchbase_c++/client.cpp
View file @
bbced206
This diff is collapsed.
Click to expand it.
src/brpc/memcache.h
View file @
bbced206
...
...
@@ -230,12 +230,6 @@ public:
static
const
char
*
status_str
(
Status
);
// Although the implementation of this function looks somewhat weird,
// we did not find a better way to provide auth failure check for user codes.
bool
IsAuthFailure
()
const
{
return
(
_err
==
"Auth failure"
);
}
private
:
bool
PopCounter
(
uint8_t
command
,
uint64_t
*
new_value
,
uint64_t
*
cas_value
);
bool
PopStore
(
uint8_t
command
,
uint64_t
*
cas_value
);
...
...
src/brpc/policy/couchbase_authenticator.cpp
View file @
bbced206
...
...
@@ -35,22 +35,21 @@ constexpr char kPadding[1] = {'\0'};
// To get the couchbase authentication protocol, see
// https://developer.couchbase.com/documentation/server/3.x/developer/dev-guide-3.0/sasl.html
int
CouchbaseAuthenticator
::
GenerateCredential
(
std
::
string
*
auth_str
)
const
{
const
brpc
::
policy
::
MemcacheRequestHeader
header
=
{
brpc
::
policy
::
MC_MAGIC_REQUEST
,
brpc
::
policy
::
MC_BINARY_SASL_AUTH
,
butil
::
HostToNet16
(
sizeof
(
kPlainAuthCommand
)
-
1
),
0
,
0
,
0
,
butil
::
HostToNet32
(
sizeof
(
kPlainAuthCommand
)
+
1
+
bucket_name_
.
length
()
*
2
+
bucket_password_
.
length
()),
0
,
0
};
butil
::
IOBuf
in
;
in
.
append
(
&
header
,
sizeof
(
header
));
in
.
append
(
kPlainAuthCommand
,
sizeof
(
kPlainAuthCommand
)
-
1
);
in
.
append
(
bucket_name_
.
c_str
(),
bucket_name_
.
length
());
in
.
append
(
kPadding
,
sizeof
(
kPadding
));
in
.
append
(
bucket_name_
.
c_str
(),
bucket_name_
.
length
());
in
.
append
(
kPadding
,
sizeof
(
kPadding
));
in
.
append
(
bucket_password_
.
c_str
(),
bucket_password_
.
length
());
auth_str
->
assign
(
in
.
to_string
().
c_str
(),
in
.
size
());
return
0
;
const
brpc
::
policy
::
MemcacheRequestHeader
header
=
{
brpc
::
policy
::
MC_MAGIC_REQUEST
,
brpc
::
policy
::
MC_BINARY_SASL_AUTH
,
butil
::
HostToNet16
(
sizeof
(
kPlainAuthCommand
)
-
1
),
0
,
0
,
0
,
butil
::
HostToNet32
(
sizeof
(
kPlainAuthCommand
)
+
1
+
bucket_name_
.
length
()
*
2
+
bucket_password_
.
length
()),
0
,
0
};
auth_str
->
clear
();
auth_str
->
append
(
reinterpret_cast
<
const
char
*>
(
&
header
),
sizeof
(
header
));
auth_str
->
append
(
kPlainAuthCommand
,
sizeof
(
kPlainAuthCommand
)
-
1
);
auth_str
->
append
(
bucket_name_
);
auth_str
->
append
(
kPadding
,
sizeof
(
kPadding
));
auth_str
->
append
(
bucket_name_
);
auth_str
->
append
(
kPadding
,
sizeof
(
kPadding
));
auth_str
->
append
(
bucket_password_
);
return
0
;
}
}
// namespace policy
...
...
src/brpc/policy/memcache_binary_protocol.cpp
View file @
bbced206
...
...
@@ -130,8 +130,11 @@ ParseResult ParseMemcacheMessage(butil::IOBuf* source,
if
(
header
->
status
!=
0
)
{
LOG
(
ERROR
)
<<
"Failed to authenticate the couchbase bucket."
<<
"All the following commands will result in auth failure."
;
return
MakeParseError
(
PARSE_ERROR_NO_RESOURCE
,
"Fail to authenticate with the couchbase bucket"
);
}
msg
=
static_cast
<
MostCommonMessage
*>
(
socket
->
release_parsing_context
());
DestroyingPtr
<
MostCommonMessage
>
auth_msg
(
static_cast
<
MostCommonMessage
*>
(
socket
->
release_parsing_context
()));
socket
->
GivebackPipelinedInfo
(
pi
);
}
else
{
if
(
++
msg
->
pi
.
count
>=
pi
.
count
)
{
...
...
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