Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
sysadmin
mattermost
mattermost-server
Commits
3ea33b76
Commit
3ea33b76
authored
Sep 20, 2018
by
Christopher Speller
Committed by
Joram Wilander
Sep 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improving token lookup. (#9436)
parent
1463df21
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
5 deletions
+7
-5
app/authentication.go
app/authentication.go
+7
-5
No files found.
app/authentication.go
View file @
3ea33b76
...
...
@@ -213,6 +213,13 @@ func (a *App) authenticateUser(user *model.User, password, mfaToken string) (*mo
func
ParseAuthTokenFromRequest
(
r
*
http
.
Request
)
(
string
,
TokenLocation
)
{
authHeader
:=
r
.
Header
.
Get
(
model
.
HEADER_AUTH
)
// Attempt to parse the token from the cookie
if
cookie
,
err
:=
r
.
Cookie
(
model
.
SESSION_COOKIE_TOKEN
);
err
==
nil
{
return
cookie
.
Value
,
TokenLocationCookie
}
// Parse the token from the header
if
len
(
authHeader
)
>
6
&&
strings
.
ToUpper
(
authHeader
[
0
:
6
])
==
model
.
HEADER_BEARER
{
// Default session token
return
authHeader
[
7
:
],
TokenLocationHeader
...
...
@@ -221,11 +228,6 @@ func ParseAuthTokenFromRequest(r *http.Request) (string, TokenLocation) {
return
authHeader
[
6
:
],
TokenLocationHeader
}
// Attempt to parse the token from the cookie
if
cookie
,
err
:=
r
.
Cookie
(
model
.
SESSION_COOKIE_TOKEN
);
err
==
nil
{
return
cookie
.
Value
,
TokenLocationCookie
}
// Attempt to parse token out of the query string
if
token
:=
r
.
URL
.
Query
()
.
Get
(
"access_token"
);
token
!=
""
{
return
token
,
TokenLocationQueryString
...
...
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