Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0a5e29d27 | ||
|
|
4a391392bb | ||
|
|
74afed9a13 | ||
|
|
55b224bc48 |
No files matched your search
@@ -122,6 +122,12 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Wide-page setting: lifts the shared shell's default max-width cap on the main content area. */
|
/* Wide-page setting: lifts the shared shell's default max-width cap on the main content area. */
|
||||||
[data-wide-layout='true'] .sc-main {
|
[data-wide-layout='true'] .sc-main {
|
||||||
width: calc(100% - 2rem);
|
width: calc(100% - 2rem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The shared paginator adds separation when it follows content directly. Inside the overview
|
||||||
|
card, the card padding provides that spacing and keeps the top and bottom insets balanced. */
|
||||||
|
.pagination-card .sc-pagination {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex-1 space-y-4 py-4">
|
<div class="flex-1 space-y-4 pb-4">
|
||||||
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
|
<div class="grid grid-cols-2 gap-4 sm:grid-cols-4">
|
||||||
<div class="rounded-lg border border-border bg-surface p-3">
|
<div class="rounded-lg border border-border bg-surface p-3">
|
||||||
<div class="text-xs text-muted-fg">Lists</div>
|
<div class="text-xs text-muted-fg">Lists</div>
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section class="rounded-lg border border-border bg-surface">
|
<section class="pagination-card rounded-lg border border-border bg-surface p-3">
|
||||||
<Pagination
|
<Pagination
|
||||||
{page}
|
{page}
|
||||||
{pageSize}
|
{pageSize}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
const pageItems = $derived(listItems.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize));
|
const pageItems = $derived(listItems.slice((page - 1) * pageSize, (page - 1) * pageSize + pageSize));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="space-y-4 py-4">
|
<div class="space-y-4 pb-4">
|
||||||
<div class="flex min-w-0 items-center gap-3">
|
<div class="flex min-w-0 items-center gap-3">
|
||||||
<Button type="button" variant="secondary" size="sm" class="shrink-0" onclick={goBack}>
|
<Button type="button" variant="secondary" size="sm" class="shrink-0" onclick={goBack}>
|
||||||
<ArrowLeft class="size-4" />
|
<ArrowLeft class="size-4" />
|
||||||
|
|||||||
@@ -28,6 +28,10 @@ type Info struct {
|
|||||||
// configuration. Consumers with independent databases can use it to read settings such as the
|
// configuration. Consumers with independent databases can use it to read settings such as the
|
||||||
// configured mount mappings.
|
// configured mount mappings.
|
||||||
ProjectConfiguratorURL string `json:"projectConfiguratorUrl"`
|
ProjectConfiguratorURL string `json:"projectConfiguratorUrl"`
|
||||||
|
// ContentScannerURL and ContentScannerSecret let services with independent databases import
|
||||||
|
// the scanner's successfully discovered media without connecting to its PostgreSQL database.
|
||||||
|
ContentScannerURL string `json:"contentScannerUrl,omitempty"`
|
||||||
|
ContentScannerSecret string `json:"contentScannerSecret,omitempty"`
|
||||||
|
|
||||||
// CarrierNodeURL is the primary CarrierNode instance's URL (CarrierNodeURLs[0], if any) - kept
|
// CarrierNodeURL is the primary CarrierNode instance's URL (CarrierNodeURLs[0], if any) - kept
|
||||||
// for the services that only ever talk to one CarrierNode instance via
|
// for the services that only ever talk to one CarrierNode instance via
|
||||||
@@ -78,6 +82,12 @@ func (s *Store) ComfyUIURL() string { return s.Get().ComfyUIURL }
|
|||||||
// ProjectConfiguratorURL is a convenience accessor for Get().ProjectConfiguratorURL.
|
// ProjectConfiguratorURL is a convenience accessor for Get().ProjectConfiguratorURL.
|
||||||
func (s *Store) ProjectConfiguratorURL() string { return s.Get().ProjectConfiguratorURL }
|
func (s *Store) ProjectConfiguratorURL() string { return s.Get().ProjectConfiguratorURL }
|
||||||
|
|
||||||
|
// ContentScannerURL is a convenience accessor for Get().ContentScannerURL.
|
||||||
|
func (s *Store) ContentScannerURL() string { return s.Get().ContentScannerURL }
|
||||||
|
|
||||||
|
// ContentScannerSecret is the credential the scanner expects on internal sync requests.
|
||||||
|
func (s *Store) ContentScannerSecret() string { return s.Get().ContentScannerSecret }
|
||||||
|
|
||||||
// CarrierNodeURL is a convenience accessor for Get().CarrierNodeURL - the natural closure to wire
|
// CarrierNodeURL is a convenience accessor for Get().CarrierNodeURL - the natural closure to wire
|
||||||
// as a single-instance carriernodeclient.Client's BaseURL: carriernodeclient.New(secret, func(ctx
|
// as a single-instance carriernodeclient.Client's BaseURL: carriernodeclient.New(secret, func(ctx
|
||||||
// context.Context) string { return store.CarrierNodeURL() }).
|
// context.Context) string { return store.CarrierNodeURL() }).
|
||||||
@@ -116,6 +126,12 @@ func (s *Store) Set(next Info) {
|
|||||||
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
|
if url := strings.TrimRight(strings.TrimSpace(next.ProjectConfiguratorURL), "/"); url != "" {
|
||||||
s.info.ProjectConfiguratorURL = url
|
s.info.ProjectConfiguratorURL = url
|
||||||
}
|
}
|
||||||
|
if url := strings.TrimRight(strings.TrimSpace(next.ContentScannerURL), "/"); url != "" {
|
||||||
|
s.info.ContentScannerURL = url
|
||||||
|
}
|
||||||
|
if secret := strings.TrimSpace(next.ContentScannerSecret); secret != "" {
|
||||||
|
s.info.ContentScannerSecret = secret
|
||||||
|
}
|
||||||
if secret := strings.TrimSpace(next.CarrierNodeSecret); secret != "" {
|
if secret := strings.TrimSpace(next.CarrierNodeSecret); secret != "" {
|
||||||
s.info.CarrierNodeSecret = secret
|
s.info.CarrierNodeSecret = secret
|
||||||
}
|
}
|
||||||
@@ -173,10 +189,11 @@ func Handler(secret string, store *Store) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
store.Set(input)
|
store.Set(input)
|
||||||
// Do not echo the CarrierNode credential to the caller. The push is
|
// Do not echo service credentials to the caller. The push is authenticated, but
|
||||||
// authenticated, but the credential is needed only by the recipient.
|
// these credentials are needed only by the recipient.
|
||||||
info := store.Get()
|
info := store.Get()
|
||||||
info.CarrierNodeSecret = ""
|
info.CarrierNodeSecret = ""
|
||||||
|
info.ContentScannerSecret = ""
|
||||||
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "info": info})
|
writeJSON(w, http.StatusOK, map[string]any{"ok": true, "info": info})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -127,7 +128,10 @@ func equalStrings(got, want []string) bool {
|
|||||||
func TestHandlerAppliesPushedInfo(t *testing.T) {
|
func TestHandlerAppliesPushedInfo(t *testing.T) {
|
||||||
store := NewStore(Info{})
|
store := NewStore(Info{})
|
||||||
handler := Handler("s3cret", store)
|
handler := Handler("s3cret", store)
|
||||||
body, _ := json.Marshal(Info{AuthGuardURL: "http://auth.example.com", CarrierNodeURL: "http://carrier.example.com", CarrierNodeSecret: "carrier-secret"})
|
body, _ := json.Marshal(Info{
|
||||||
|
AuthGuardURL: "http://auth.example.com", CarrierNodeURL: "http://carrier.example.com", CarrierNodeSecret: "carrier-secret",
|
||||||
|
ContentScannerURL: "http://scanner.example.com/", ContentScannerSecret: "scanner-secret",
|
||||||
|
})
|
||||||
|
|
||||||
req := httptest.NewRequest(http.MethodPut, "/api/core-services/internal", bytes.NewReader(body))
|
req := httptest.NewRequest(http.MethodPut, "/api/core-services/internal", bytes.NewReader(body))
|
||||||
req.Header.Set("X-Internal-Auth", "s3cret")
|
req.Header.Set("X-Internal-Auth", "s3cret")
|
||||||
@@ -138,7 +142,10 @@ func TestHandlerAppliesPushedInfo(t *testing.T) {
|
|||||||
t.Fatalf("status = %d, want 200: %s", rec.Code, rec.Body.String())
|
t.Fatalf("status = %d, want 200: %s", rec.Code, rec.Body.String())
|
||||||
}
|
}
|
||||||
got := store.Get()
|
got := store.Get()
|
||||||
if got.AuthGuardURL != "http://auth.example.com" || got.CarrierNodeURL != "http://carrier.example.com" || got.CarrierNodeSecret != "carrier-secret" {
|
if got.AuthGuardURL != "http://auth.example.com" || got.CarrierNodeURL != "http://carrier.example.com" || got.CarrierNodeSecret != "carrier-secret" || got.ContentScannerURL != "http://scanner.example.com" || got.ContentScannerSecret != "scanner-secret" {
|
||||||
t.Fatalf("store = %+v, want pushed values applied", got)
|
t.Fatalf("store = %+v, want pushed values applied", got)
|
||||||
}
|
}
|
||||||
|
if strings.Contains(rec.Body.String(), "scanner-secret") {
|
||||||
|
t.Fatal("response echoed the ContentScanner secret")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -200,6 +200,17 @@ func (c *Core) thumbnailMediaIdentifier(w http.ResponseWriter, r *http.Request,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var thumbnailID string
|
||||||
|
if err := c.db.QueryRow(r.Context(), `
|
||||||
|
SELECT t.id::text
|
||||||
|
FROM thumbnails t
|
||||||
|
JOIN media m ON m.id = t.media_id OR t.source_path = COALESCE(NULLIF(m.file_path, ''), m.media_key)
|
||||||
|
WHERE m.media_key=$1 OR CAST(m.id AS TEXT)=$1
|
||||||
|
ORDER BY t.created_at DESC
|
||||||
|
LIMIT 1`, id).Scan(&thumbnailID); err == nil && SafeRelative(thumbnailID) {
|
||||||
|
c.carrierNode.Proxy(w, r, "/thumbnails/"+thumbnailID+".jpg")
|
||||||
|
return
|
||||||
|
}
|
||||||
record, err := c.findMedia(r.Context(), id)
|
record, err := c.findMedia(r.Context(), id)
|
||||||
if err != nil || !isImagePath(record.FilePath) {
|
if err != nil || !isImagePath(record.FilePath) {
|
||||||
writeError(w, http.StatusNotFound, "thumbnail not found")
|
writeError(w, http.StatusNotFound, "thumbnail not found")
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ auth_client = AuthClient("") # pending: no URL yet, still safe to use
|
|||||||
core_config = CoreConfigStore(CoreConfigInfo(auth_guard_url=""))
|
core_config = CoreConfigStore(CoreConfigInfo(auth_guard_url=""))
|
||||||
core_config.on_update(lambda info: auth_client.set_base_url(info.auth_guard_url))
|
core_config.on_update(lambda info: auth_client.set_base_url(info.auth_guard_url))
|
||||||
|
|
||||||
|
|
||||||
# in your framework's route for PUT /api/core-services/internal:
|
# in your framework's route for PUT /api/core-services/internal:
|
||||||
async def push_core_services(request):
|
async def push_core_services(request):
|
||||||
if request.headers.get("X-Internal-Auth") != SECRET:
|
if request.headers.get("X-Internal-Auth") != SECRET:
|
||||||
@@ -128,19 +129,27 @@ completed" claim flag, and optionally a "require login" toggle) and calls
|
|||||||
from shared_backend.authclient import AuthClient
|
from shared_backend.authclient import AuthClient
|
||||||
from shared_backend.authproxy import ProxyStore, build_auth_router
|
from shared_backend.authproxy import ProxyStore, build_auth_router
|
||||||
|
|
||||||
|
|
||||||
class MyStore(ProxyStore):
|
class MyStore(ProxyStore):
|
||||||
async def login_required(self) -> bool: return True
|
async def login_required(self) -> bool:
|
||||||
async def set_login_required(self, required: bool) -> None: pass
|
return True
|
||||||
async def is_setup_claimed(self) -> bool: ... # your own table
|
|
||||||
async def try_claim_setup(self) -> bool: ... # your own table
|
async def set_login_required(self, required: bool) -> None:
|
||||||
async def unclaim_setup(self) -> None: ... # your own table
|
pass
|
||||||
|
|
||||||
|
async def is_setup_claimed(self) -> bool: ... # your own table
|
||||||
|
async def try_claim_setup(self) -> bool: ... # your own table
|
||||||
|
async def unclaim_setup(self) -> None: ... # your own table
|
||||||
|
|
||||||
|
|
||||||
def get_client(request):
|
def get_client(request):
|
||||||
return request.app.state.auth_client # AuthClient | None, or None in auth-disabled mode
|
return request.app.state.auth_client # AuthClient | None, or None in auth-disabled mode
|
||||||
|
|
||||||
|
|
||||||
def get_store(request):
|
def get_store(request):
|
||||||
return request.app.state.auth_store
|
return request.app.state.auth_store
|
||||||
|
|
||||||
|
|
||||||
app.include_router(
|
app.include_router(
|
||||||
build_auth_router(get_client, get_store, legacy_cookie_name="myproject_session"),
|
build_auth_router(get_client, get_store, legacy_cookie_name="myproject_session"),
|
||||||
prefix="/api/auth",
|
prefix="/api/auth",
|
||||||
|
|||||||
@@ -574,7 +574,10 @@ def build_auth_router(
|
|||||||
store: ProxyStore = Depends(get_store), # noqa: B008
|
store: ProxyStore = Depends(get_store), # noqa: B008
|
||||||
) -> dict[str, bool]:
|
) -> dict[str, bool]:
|
||||||
nonlocal login_required_override
|
nonlocal login_required_override
|
||||||
if not configured_internal_secret or request.headers.get("X-Internal-Auth") != configured_internal_secret:
|
if (
|
||||||
|
not configured_internal_secret
|
||||||
|
or request.headers.get("X-Internal-Auth") != configured_internal_secret
|
||||||
|
):
|
||||||
raise HTTPException(status_code=401, detail="internal service authentication required")
|
raise HTTPException(status_code=401, detail="internal service authentication required")
|
||||||
await store.set_login_required(req.loginRequired)
|
await store.set_login_required(req.loginRequired)
|
||||||
login_required_override = req.loginRequired
|
login_required_override = req.loginRequired
|
||||||
|
|||||||
@@ -123,7 +123,9 @@ class AccessSettingsTests(unittest.TestCase):
|
|||||||
|
|
||||||
def test_internal_update_disables_login_and_uses_admin_identity(self) -> None:
|
def test_internal_update_disables_login_and_uses_admin_identity(self) -> None:
|
||||||
store = _FakeStore(login_required=True)
|
store = _FakeStore(login_required=True)
|
||||||
client = TestClient(_build_app(store, _FakeClient(setup_required=False), internal_secret="secret"))
|
client = TestClient(
|
||||||
|
_build_app(store, _FakeClient(setup_required=False), internal_secret="secret")
|
||||||
|
)
|
||||||
|
|
||||||
response = client.put(
|
response = client.put(
|
||||||
"/api/auth/access/internal",
|
"/api/auth/access/internal",
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ from shared_backend.coreconfig import Info, Store
|
|||||||
|
|
||||||
class StoreDefaultsTests(unittest.TestCase):
|
class StoreDefaultsTests(unittest.TestCase):
|
||||||
def test_seeds_from_fallback(self):
|
def test_seeds_from_fallback(self):
|
||||||
store = Store(Info(auth_guard_url="http://auth.example.com", carrier_node_url="http://carrier.example.com"))
|
store = Store(
|
||||||
|
Info(
|
||||||
|
auth_guard_url="http://auth.example.com",
|
||||||
|
carrier_node_url="http://carrier.example.com",
|
||||||
|
)
|
||||||
|
)
|
||||||
info = store.get()
|
info = store.get()
|
||||||
self.assertEqual(info.auth_guard_url, "http://auth.example.com")
|
self.assertEqual(info.auth_guard_url, "http://auth.example.com")
|
||||||
self.assertEqual(info.carrier_node_url, "http://carrier.example.com")
|
self.assertEqual(info.carrier_node_url, "http://carrier.example.com")
|
||||||
@@ -20,7 +25,12 @@ class StoreDefaultsTests(unittest.TestCase):
|
|||||||
|
|
||||||
class StoreSetTests(unittest.TestCase):
|
class StoreSetTests(unittest.TestCase):
|
||||||
def test_partial_push_does_not_clobber_other_field(self):
|
def test_partial_push_does_not_clobber_other_field(self):
|
||||||
store = Store(Info(auth_guard_url="http://auth.example.com", carrier_node_url="http://carrier.example.com"))
|
store = Store(
|
||||||
|
Info(
|
||||||
|
auth_guard_url="http://auth.example.com",
|
||||||
|
carrier_node_url="http://carrier.example.com",
|
||||||
|
)
|
||||||
|
)
|
||||||
store.set(Info(carrier_node_url="http://carrier2.example.com"))
|
store.set(Info(carrier_node_url="http://carrier2.example.com"))
|
||||||
info = store.get()
|
info = store.get()
|
||||||
self.assertEqual(info.auth_guard_url, "http://auth.example.com")
|
self.assertEqual(info.auth_guard_url, "http://auth.example.com")
|
||||||
@@ -46,7 +56,9 @@ class StoreSetTests(unittest.TestCase):
|
|||||||
"carrierNodeUrls": ["http://carrier.example.com", "http://carrier2.example.com"],
|
"carrierNodeUrls": ["http://carrier.example.com", "http://carrier2.example.com"],
|
||||||
}
|
}
|
||||||
info = Info.from_json(payload)
|
info = Info.from_json(payload)
|
||||||
self.assertEqual(info.carrier_node_urls, ["http://carrier.example.com", "http://carrier2.example.com"])
|
self.assertEqual(
|
||||||
|
info.carrier_node_urls, ["http://carrier.example.com", "http://carrier2.example.com"]
|
||||||
|
)
|
||||||
self.assertEqual(info.to_json()["carrierNodeUrl"], "http://carrier.example.com")
|
self.assertEqual(info.to_json()["carrierNodeUrl"], "http://carrier.example.com")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user