snapshot of https://github.com/cortezaproject/corteza.git (2024.9.x, 2026-09-18; blobs > 131072B omitted)
Some checks failed
SonarQube / SonarQube (push) Failing after 5m28s
E2e test on main branch push / server and client test (map[name:admin port:8080]) (push) Failing after 3m33s
Server and lib tests / Library test (js) (push) Failing after 1m36s
Server and lib tests / Library test (vue) (push) Successful in 2m24s
Server and lib tests / Web client test (admin) (push) Successful in 2m52s
Server and lib tests / Web client test (compose) (push) Successful in 3m23s
Server and lib tests / Web client test (discovery) (push) Successful in 2m49s
Server and lib tests / Web client test (one) (push) Successful in 2m52s
Server and lib tests / Web client test (privacy) (push) Successful in 2m44s
Server and lib tests / Web client test (reporter) (push) Successful in 2m56s
Server and lib tests / Web client test (workflow) (push) Successful in 3m0s
Server and lib tests / Server tests (push) Failing after 4m55s
E2e test on main branch push / notify-failure (push) Failing after 9s
Server and lib tests / Send matrix testing notification (push) Successful in 2s
Mark stale issues and pull requests / stale (push) Successful in 40s

This commit is contained in:
upstream-mirror
2026-09-18 01:22:23 +05:00
commit 7e385fc126
8391 changed files with 1766236 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
language: go
go:
- 1.4
- 1.5
- 1.6
install:
- go get github.com/stretchr/testify/assert

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2016 99designs
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,41 @@
basicauth-go
=================
[![GoDoc](https://godoc.org/github.com/99designs/basicauth-go?status.svg)](https://godoc.org/github.com/99designs/basicauth-go)
[![Build Status](https://travis-ci.org/99designs/basicauth-go.svg)](https://travis-ci.org/99designs/basicauth-go)
golang middleware for HTTP basic auth.
```go
// Chi
router.Use(basicauth.New("MyRealm", map[string][]string{
"bob": {"password1", "password2"},
}))
// Manual wrapping
middleware := basicauth.New("MyRealm", map[string][]string{
"bob": {"password1", "password2"},
})
h := middlware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request)) {
/// do stuff
})
log.Fatal(http.ListenAndServe(":8080", h))
```
### env loading
If your environment looks like this:
```bash
SOME_PREFIX_BOB=password
SOME_PREFIX_JANE=password1,password2
```
you can load it like this:
```go
middleware := basicauth.NewFromEnv("MyRealm", "SOME_PREFIX")
```

View File

@@ -0,0 +1,41 @@
package basicauth
import (
"fmt"
"net/http"
)
// New returns a piece of middleware that will allow access only
// if the provided credentials match within the given service
// otherwise it will return a 401 and not call the next handler.
func New(realm string, credentials map[string][]string) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
username, password, ok := r.BasicAuth()
if !ok {
unauthorized(w, realm)
return
}
validPasswords, userFound := credentials[username]
if !userFound {
unauthorized(w, realm)
return
}
for _, validPassword := range validPasswords {
if password == validPassword {
next.ServeHTTP(w, r)
return
}
}
unauthorized(w, realm)
})
}
}
func unauthorized(w http.ResponseWriter, realm string) {
w.Header().Add("WWW-Authenticate", fmt.Sprintf(`Basic realm="%s"`, realm))
w.WriteHeader(http.StatusUnauthorized)
}

34
server/vendor/github.com/99designs/basicauth-go/env.go generated vendored Normal file
View File

@@ -0,0 +1,34 @@
package basicauth
import (
"fmt"
"net/http"
"os"
"regexp"
"strings"
)
// NewFromEnv reads a set of credentials in from environment variables in
// the format {PREFIX}{USERNAME|tolower}=password1,password2 and returns
// middleware that will validate incoming requests.
func NewFromEnv(realm, prefix string) func(http.Handler) http.Handler {
credentials := map[string][]string{}
re := regexp.MustCompile(fmt.Sprintf("^%s(?P<username>.*)$", strings.ToUpper(prefix)))
for _, envVar := range os.Environ() {
name, value := split2(envVar, "=")
if res := re.FindStringSubmatch(name); res != nil {
username := strings.ToLower(res[1])
credentials[username] = strings.Split(value, ",")
}
}
return New(realm, credentials)
}
func split2(s, sep string) (string, string) {
res := strings.SplitN(s, sep, 2)
return res[0], res[1]
}