Skip to content

Commit

Permalink
add changelog
Browse files Browse the repository at this point in the history
remove unused mux
cleanup k6 test
  • Loading branch information
Florian Schade committed Nov 26, 2020
1 parent 11ba46e commit cb2e2a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/accounts-cache-password-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Change: Cache password validation

Tags: accounts

The password validity check for requests like `login eq '%s' and password eq '%s'` is now cached for 10 minutes.
This improves the performance for basic auth requests.

https://github.com/owncloud/ocis/pull/958
13 changes: 5 additions & 8 deletions proxy/pkg/middleware/basic_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package middleware

import (
"fmt"
"net/http"
"strings"
"sync"

accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/oidc"
"net/http"
"strings"
)

const publicFilesEndpoint = "/remote.php/dav/public-files/"
Expand Down Expand Up @@ -59,22 +57,21 @@ type basicAuth struct {
logger log.Logger
enabled bool
accountsClient accounts.AccountsService
m sync.Mutex
}

func (m *basicAuth) isPublicLink(req *http.Request) bool {
func (m basicAuth) isPublicLink(req *http.Request) bool {
login, _, ok := req.BasicAuth()

return ok && login == "public" && strings.HasPrefix(req.URL.Path, publicFilesEndpoint)
}

func (m *basicAuth) isBasicAuth(req *http.Request) bool {
func (m basicAuth) isBasicAuth(req *http.Request) bool {
login, password, ok := req.BasicAuth()

return m.enabled && ok && login != "" && password != ""
}

func (m *basicAuth) getAccount(req *http.Request) (*accounts.Account, bool) {
func (m basicAuth) getAccount(req *http.Request) (*accounts.Account, bool) {
login, password, _ := req.BasicAuth()

account, status := getAccount(
Expand Down
4 changes: 2 additions & 2 deletions tests/k6/src/test-issue-162.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {sleep, check} from 'k6';
import {Options} from "k6/options";
import {defaults, api, utils} from "./lib";
import {defaults, api} from "./lib";

const files = {
'kb_50.jpg': open('./_files/kb_50.jpg', 'b'),
Expand All @@ -13,7 +13,7 @@ export let options: Options = {
};

export default () => {
const res = api.uploadFile(defaults.accounts.einstein, files['kb_50.jpg'], `kb_50-${utils.randomString()}.jpg`)
const res = api.uploadFile(defaults.accounts.einstein, files['kb_50.jpg'], `kb_50-${__VU}-${__ITER}.jpg`)

check(res, {
'status is 201': () => res.status === 201,
Expand Down

0 comments on commit cb2e2a3

Please sign in to comment.