feat: add browser upload queue and trusted sessions with bounded projections
Build and publish container images / images (push) Successful in 11m37s
Release container images / release (push) Successful in 22s

This commit is contained in:
Anya Tokugawa committed 2026-11-08 20:27:04 +09:00
1 parent 84d52390f9
commit b90aef79d0
79 files changed
+1962 -196

No files matched your search

+28 -2
View File
@@ -28,6 +28,14 @@ func cliForm(s *Server, path string, form url.Values, cookie, origin string) *ht
}
func TestCLIAuthOIDCFlow(t *testing.T) {
for _, remember := range []bool{false, true} {
t.Run(map[bool]string{false: "normal", true: "trusted"}[remember], func(t *testing.T) {
testCLIAuthOIDCFlow(t, remember)
})
}
}
func testCLIAuthOIDCFlow(t *testing.T, remember bool) {
s, api, domain := configFixture(t)
principal := s.mustCLIPrincipal(t, domain, api)
// An enrolled local factor must not add a second challenge to OIDC consent.
@@ -43,7 +51,13 @@ func TestCLIAuthOIDCFlow(t *testing.T) {
}
verifier := strings.Repeat("x", 43)
sum := sha256.Sum256([]byte(verifier))
start := cliForm(s, "/_/auth/cli/start", url.Values{"code_challenge": {base64.RawURLEncoding.EncodeToString(sum[:])}, "code_challenge_method": {"S256"}}, "", "")
startForm := url.Values{"code_challenge": {base64.RawURLEncoding.EncodeToString(sum[:])}, "code_challenge_method": {"S256"}}
expectedSeconds := 24 * 60 * 60
if remember {
startForm.Set("remember", "1")
expectedSeconds *= 30
}
start := cliForm(s, "/_/auth/cli/start", startForm, "", "")
if start.Code != 200 {
t.Fatalf("start %d %s", start.Code, start.Body.String())
}
@@ -63,7 +77,12 @@ func TestCLIAuthOIDCFlow(t *testing.T) {
t.Fatalf("verify landing: %d %s", verify.Code, verify.Body.String())
}
begin := httptest.NewRecorder()
s.beginOIDC(begin, httptest.NewRequest("GET", "https://localhost/_/auth/oidc?cli="+id, nil))
// The browser query must not override the CLI's persisted choice.
tamperedRemember := "1"
if remember {
tamperedRemember = "0"
}
s.beginOIDC(begin, httptest.NewRequest("GET", "https://localhost/_/auth/oidc?cli="+id+"&remember="+tamperedRemember, nil))
if begin.Code != 302 {
t.Fatalf("oidc begin %d %s", begin.Code, begin.Body.String())
}
@@ -86,6 +105,9 @@ func TestCLIAuthOIDCFlow(t *testing.T) {
for _, cookie := range complete.Result().Cookies() {
if cookie.Name == authCookieName {
browser = cookie.Value
if cookie.MaxAge != expectedSeconds {
t.Fatalf("cookie lifetime %d, want %d", cookie.MaxAge, expectedSeconds)
}
}
}
if browser == "" {
@@ -128,6 +150,7 @@ func TestCLIAuthOIDCFlow(t *testing.T) {
var result struct {
Token string `json:"access_token"`
Username string `json:"username"`
Expires int `json:"expires_in"`
}
if err := json.Unmarshal(exchange.Body.Bytes(), &result); err != nil {
t.Fatal(err)
@@ -135,6 +158,9 @@ func TestCLIAuthOIDCFlow(t *testing.T) {
if !strings.HasPrefix(result.Token, "pw_api_") || result.Username != "admin" || result.Token == browser {
t.Fatal("invalid delegated credential")
}
if result.Expires > expectedSeconds || result.Expires < expectedSeconds-10 {
t.Fatalf("CLI lifetime %d, want approximately %d", result.Expires, expectedSeconds)
}
if _, err := s.store.PrincipalForSession(domain, result.Token); err != nil {
t.Fatal(err)
}