Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc fixes #560

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please revert 6fc49c2 - the package naming is deliberate

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package _auth_cache
package auth_cache

import (
"errors"
Expand Down
6 changes: 3 additions & 3 deletions api/r0/logout.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/t2bot/matrix-media-repo/api/apimeta"
"github.com/t2bot/matrix-media-repo/api/responses"

"github.com/t2bot/matrix-media-repo/api/_auth_cache"
"github.com/t2bot/matrix-media-repo/api/auth_cache"
"github.com/t2bot/matrix-media-repo/common/rcontext"
)

func Logout(r *http.Request, rctx rcontext.RequestContext, user apimeta.UserInfo) interface{} {
err := _auth_cache.InvalidateToken(rctx, user.AccessToken, user.UserId)
err := auth_cache.InvalidateToken(rctx, user.AccessToken, user.UserId)
if err != nil {
rctx.Log.Error(err)
sentry.CaptureException(err)
Expand All @@ -23,7 +23,7 @@ func Logout(r *http.Request, rctx rcontext.RequestContext, user apimeta.UserInfo
}

func LogoutAll(r *http.Request, rctx rcontext.RequestContext, user apimeta.UserInfo) interface{} {
err := _auth_cache.InvalidateAllTokens(rctx, user.AccessToken, user.UserId)
err := auth_cache.InvalidateAllTokens(rctx, user.AccessToken, user.UserId)
if err != nil {
rctx.Log.Error(err)
sentry.CaptureException(err)
Expand Down
4 changes: 2 additions & 2 deletions api/routers/97-optional-access-token.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/getsentry/sentry-go"
"github.com/sirupsen/logrus"
"github.com/t2bot/matrix-media-repo/api/_auth_cache"
"github.com/t2bot/matrix-media-repo/api/apimeta"
"github.com/t2bot/matrix-media-repo/api/auth_cache"
"github.com/t2bot/matrix-media-repo/api/responses"
"github.com/t2bot/matrix-media-repo/common/config"
"github.com/t2bot/matrix-media-repo/common/rcontext"
Expand All @@ -34,7 +34,7 @@ func OptionalAccessToken(generator GeneratorWithUserFn) GeneratorFn {
})
}
appserviceUserId := util.GetAppserviceUserIdFromRequest(r)
userId, err := _auth_cache.GetUserId(ctx, accessToken, appserviceUserId)
userId, err := auth_cache.GetUserId(ctx, accessToken, appserviceUserId)
if err != nil {
if !errors.Is(err, matrix.ErrInvalidToken) {
sentry.CaptureException(err)
Expand Down
4 changes: 2 additions & 2 deletions api/routers/97-require-access-token.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (

"github.com/getsentry/sentry-go"
"github.com/sirupsen/logrus"
"github.com/t2bot/matrix-media-repo/api/_auth_cache"
"github.com/t2bot/matrix-media-repo/api/apimeta"
"github.com/t2bot/matrix-media-repo/api/auth_cache"
"github.com/t2bot/matrix-media-repo/api/responses"
"github.com/t2bot/matrix-media-repo/common"
"github.com/t2bot/matrix-media-repo/common/config"
Expand Down Expand Up @@ -37,7 +37,7 @@ func RequireAccessToken(generator GeneratorWithUserFn) GeneratorFn {
})
}
appserviceUserId := util.GetAppserviceUserIdFromRequest(r)
userId, err := _auth_cache.GetUserId(ctx, accessToken, appserviceUserId)
userId, err := auth_cache.GetUserId(ctx, accessToken, appserviceUserId)
if err != nil || userId == "" {
if errors.Is(err, matrix.ErrGuestToken) {
return responses.GuestAuthFailed()
Expand Down
4 changes: 2 additions & 2 deletions cmd/workers/media_repo/reloads.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"github.com/sirupsen/logrus"
"github.com/t2bot/matrix-media-repo/api"
"github.com/t2bot/matrix-media-repo/api/_auth_cache"
"github.com/t2bot/matrix-media-repo/api/auth_cache"
"github.com/t2bot/matrix-media-repo/common/config"
"github.com/t2bot/matrix-media-repo/common/globals"
"github.com/t2bot/matrix-media-repo/common/runtime"
Expand Down Expand Up @@ -136,7 +136,7 @@ func reloadAccessTokensOnChan(reloadChan chan bool) {
for {
shouldReload := <-reloadChan
if shouldReload {
_auth_cache.FlushCache()
auth_cache.FlushCache()
} else {
return // received stop
}
Expand Down