Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nakama
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
public-projects
Nakama
Commits
1c48dfdc
Unverified
Commit
1c48dfdc
authored
3 years ago
by
Jason Knight
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Try http_key auth method before authorization based auth method in RPC functions. (#772)
parent
cc5ba4d9
Branches
Branches containing commit
Tags
Tags containing commit
Loading
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/api_rpc.go
+10
-10
10 additions, 10 deletions
server/api_rpc.go
with
10 additions
and
10 deletions
server/api_rpc.go
+
10
−
10
View file @
1c48dfdc
...
@@ -51,25 +51,25 @@ func (s *ApiServer) RpcFuncHttp(w http.ResponseWriter, r *http.Request) {
...
@@ -51,25 +51,25 @@ func (s *ApiServer) RpcFuncHttp(w http.ResponseWriter, r *http.Request) {
var
username
string
var
username
string
var
vars
map
[
string
]
string
var
vars
map
[
string
]
string
var
expiry
int64
var
expiry
int64
if
auth
:=
r
.
Header
[
"Authorization"
];
len
(
auth
)
>=
1
{
if
httpKey
:=
queryParams
.
Get
(
"http_key"
);
httpKey
!=
""
{
var
token
string
if
httpKey
!=
s
.
config
.
GetRuntime
()
.
HTTPKey
{
userID
,
username
,
vars
,
expiry
,
token
,
isTokenAuth
=
parseBearerAuth
([]
byte
(
s
.
config
.
GetSession
()
.
EncryptionKey
),
auth
[
0
])
// HTTP key did not match.
if
!
isTokenAuth
||
!
s
.
sessionCache
.
IsValidSession
(
userID
,
expiry
,
token
)
{
// Auth token not valid or expired.
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
_
,
err
:=
w
.
Write
(
authToken
InvalidBytes
)
_
,
err
:=
w
.
Write
(
httpKey
InvalidBytes
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
logger
.
Debug
(
"Error writing response to client"
,
zap
.
Error
(
err
))
s
.
logger
.
Debug
(
"Error writing response to client"
,
zap
.
Error
(
err
))
}
}
return
return
}
}
}
else
if
httpKey
:=
queryParams
.
Get
(
"http_key"
);
httpKey
!=
""
{
}
else
if
auth
:=
r
.
Header
[
"Authorization"
];
len
(
auth
)
>=
1
{
if
httpKey
!=
s
.
config
.
GetRuntime
()
.
HTTPKey
{
var
token
string
// HTTP key did not match.
userID
,
username
,
vars
,
expiry
,
token
,
isTokenAuth
=
parseBearerAuth
([]
byte
(
s
.
config
.
GetSession
()
.
EncryptionKey
),
auth
[
0
])
if
!
isTokenAuth
||
!
s
.
sessionCache
.
IsValidSession
(
userID
,
expiry
,
token
)
{
// Auth token not valid or expired.
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
w
.
Header
()
.
Set
(
"content-type"
,
"application/json"
)
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
w
.
WriteHeader
(
http
.
StatusUnauthorized
)
_
,
err
:=
w
.
Write
(
httpKey
InvalidBytes
)
_
,
err
:=
w
.
Write
(
authToken
InvalidBytes
)
if
err
!=
nil
{
if
err
!=
nil
{
s
.
logger
.
Debug
(
"Error writing response to client"
,
zap
.
Error
(
err
))
s
.
logger
.
Debug
(
"Error writing response to client"
,
zap
.
Error
(
err
))
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment