Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
matrix-media-repo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
matrix-media-repo
Commits
ab171fc9
Commit
ab171fc9
authored
5 years ago
by
Travis Ralston
Browse files
Options
Downloads
Patches
Plain Diff
Return a 401 error when a token isn't provided
Fixes
https://github.com/turt2live/matrix-media-repo/issues/206
parent
641eddc9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/auth.go
+2
-1
2 additions, 1 deletion
api/auth.go
common/errorcodes.go
+1
-0
1 addition, 0 deletions
common/errorcodes.go
with
3 additions
and
1 deletion
api/auth.go
+
2
−
1
View file @
ab171fc9
...
@@ -4,6 +4,7 @@ import (
...
@@ -4,6 +4,7 @@ import (
"net/http"
"net/http"
"github.com/sirupsen/logrus"
"github.com/sirupsen/logrus"
"github.com/turt2live/matrix-media-repo/common"
"github.com/turt2live/matrix-media-repo/common/config"
"github.com/turt2live/matrix-media-repo/common/config"
"github.com/turt2live/matrix-media-repo/matrix"
"github.com/turt2live/matrix-media-repo/matrix"
"github.com/turt2live/matrix-media-repo/util"
"github.com/turt2live/matrix-media-repo/util"
...
@@ -20,7 +21,7 @@ func AccessTokenRequiredRoute(next func(r *http.Request, log *logrus.Entry, user
...
@@ -20,7 +21,7 @@ func AccessTokenRequiredRoute(next func(r *http.Request, log *logrus.Entry, user
accessToken
:=
util
.
GetAccessTokenFromRequest
(
r
)
accessToken
:=
util
.
GetAccessTokenFromRequest
(
r
)
if
accessToken
==
""
{
if
accessToken
==
""
{
log
.
Error
(
"Error: no token provided (required)"
)
log
.
Error
(
"Error: no token provided (required)"
)
return
InternalServerError
(
"Error no token provided (required)"
)
return
&
ErrorResponse
{
common
.
ErrCodeMissingToken
,
"no token provided (required)"
,
common
.
ErrCodeUnknownToken
}
}
}
if
config
.
Get
()
.
SharedSecret
.
Enabled
&&
accessToken
==
config
.
Get
()
.
SharedSecret
.
Token
{
if
config
.
Get
()
.
SharedSecret
.
Enabled
&&
accessToken
==
config
.
Get
()
.
SharedSecret
.
Token
{
log
=
log
.
WithFields
(
logrus
.
Fields
{
"isRepoAdmin"
:
true
})
log
=
log
.
WithFields
(
logrus
.
Fields
{
"isRepoAdmin"
:
true
})
...
...
This diff is collapsed.
Click to expand it.
common/errorcodes.go
+
1
−
0
View file @
ab171fc9
...
@@ -5,6 +5,7 @@ const ErrCodeHostNotFound = "M_HOST_NOT_FOUND"
...
@@ -5,6 +5,7 @@ const ErrCodeHostNotFound = "M_HOST_NOT_FOUND"
const
ErrCodeHostBlacklisted
=
"M_HOST_BLACKLISTED"
const
ErrCodeHostBlacklisted
=
"M_HOST_BLACKLISTED"
const
ErrCodeNotFound
=
"M_NOT_FOUND"
const
ErrCodeNotFound
=
"M_NOT_FOUND"
const
ErrCodeUnknownToken
=
"M_UNKNOWN_TOKEN"
const
ErrCodeUnknownToken
=
"M_UNKNOWN_TOKEN"
const
ErrCodeMissingToken
=
"M_MISSING_TOKEN"
const
ErrCodeMediaTooLarge
=
"M_MEDIA_TOO_LARGE"
const
ErrCodeMediaTooLarge
=
"M_MEDIA_TOO_LARGE"
const
ErrCodeMediaTooSmall
=
"M_MEDIA_TOO_SMALL"
const
ErrCodeMediaTooSmall
=
"M_MEDIA_TOO_SMALL"
const
ErrCodeTooLarge
=
"M_TOO_LARGE"
const
ErrCodeTooLarge
=
"M_TOO_LARGE"
...
...
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