Enable CLI language-aware editing and reuse OIDC authentication
This commit is contained in:
1 parent
5821254535
commit
93f4ecb8f4
11 files changed
+264
-84
No files matched your search
@@ -28,7 +28,12 @@ func cliForm(s *Server, path string, form url.Values, cookie, origin string) *ht
|
||||
}
|
||||
|
||||
func TestCLIAuthOIDCFlow(t *testing.T) {
|
||||
s, _, domain := configFixture(t)
|
||||
s, api, domain := configFixture(t)
|
||||
principal := s.mustCLIPrincipal(t, domain, api)
|
||||
// An enrolled local factor must not add a second challenge to OIDC consent.
|
||||
if _, err := s.store.DB.Exec(`INSERT INTO auth_credentials(uuid,principal_uuid,kind,identifier,secret_hash,created_at_ms,updated_at_ms,enabled) VALUES('cli-test-totp',?,'totp',?,'synthetic-invalid',1,1,1)`, principal, principal); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
p := newOIDCTestProvider(t)
|
||||
previous := oidcVerifier
|
||||
oidcVerifier = p.verifier
|
||||
@@ -93,6 +98,9 @@ func TestCLIAuthOIDCFlow(t *testing.T) {
|
||||
if w.Code != 200 || !strings.Contains(w.Body.String(), `name="user_code"`) || !strings.Contains(w.Body.String(), cliConsentCSRF(browser, id)) {
|
||||
t.Fatalf("consent %d %s", w.Code, w.Body.String())
|
||||
}
|
||||
if strings.Contains(w.Body.String(), `name="totp"`) {
|
||||
t.Fatal("OIDC consent repeated local TOTP")
|
||||
}
|
||||
form := url.Values{"request": {id}, "csrf": {cliConsentCSRF(browser, id)}, "user_code": {grant.Code}, "decision": {"approve"}}
|
||||
if w := cliForm(s, "/_/auth/cli/verify", form, browser, "https://evil.example"); w.Code != 403 {
|
||||
t.Fatal("cross-origin approval accepted")
|
||||
|
||||
Reference in new issue
Block a user