Service d'accès : les projets du client au clic sur « Generate reply »
- acces/ : conteneur (bibliothèque standard) qui répond à l'outil get_customer_access de LibreDesk. L'e-mail du contact (X-Libredesk-Contact-Email, ajouté par LibreDesk, jamais par le LLM) est traduit en compte auth0|… par l'export d'Auth0 (utilisateurs.json), puis en projets par les UserGroup de la base du dashboard (database.db, lecture seule) : project, serial, role. Jeton Bearer obligatoire ; fichier ou base illisible → 502, jamais une liste vide. - exporter_utilisateurs.py : l'export Auth0, lancé avec le .env du dashboard. - Données et secrets hors de git (acces/.env, database.db, utilisateurs.json), .env interdit à Claude. - Production : en service provisoire sur le PC de Maxime (point 14), vérifié sur un vrai « Generate reply » (1 projet renvoyé). Architecture draw.io : la partie accès. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2f7ec25731
commit
369f2e0a44
12 files changed
+452
-16
No files matched your search
+69
-15
@@ -1,6 +1,6 @@
|
||||
<mxfile host="Electron">
|
||||
<diagram name="1. Architecture" id="arch">
|
||||
<mxGraphModel dx="2914" dy="841" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1500" pageHeight="900" math="0" shadow="0">
|
||||
<mxGraphModel dx="2678" dy="701" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="1500" pageHeight="900" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
@@ -18,13 +18,13 @@
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="arch-2" parent="1" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" value="Customer" vertex="1">
|
||||
<mxGeometry height="70" width="40" x="-170" y="205" as="geometry" />
|
||||
<mxGeometry height="70" width="40" x="-220" y="205" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="9YVmYg31Dtc29ZtFE1oE-3" edge="1" parent="1" source="arch-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;fillColor=#60a917;strokeColor=#2D7600;" target="arch-2">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="-270" y="470" />
|
||||
<mxPoint x="-270" y="240" />
|
||||
<mxPoint x="-320" y="470" />
|
||||
<mxPoint x="-320" y="240" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
@@ -34,7 +34,7 @@
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="arch-3" parent="1" style="shape=umlActor;verticalLabelPosition=bottom;verticalAlign=top;html=1;outlineConnect=0;" value="Support agent<div>(human)</div>" vertex="1">
|
||||
<mxGeometry height="70" width="40" x="-170" y="435" as="geometry" />
|
||||
<mxGeometry height="70" width="40" x="-220" y="435" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="arch-4" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" value="<b>Anthropic</b><div>https://api.anthropic.com/v1</div>" vertex="1">
|
||||
<mxGeometry height="60" width="180" x="225" y="10" as="geometry" />
|
||||
@@ -45,13 +45,13 @@
|
||||
<mxCell id="9YVmYg31Dtc29ZtFE1oE-2" edge="1" parent="1" source="arch-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;" target="arch-3">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint y="470" />
|
||||
<mxPoint y="470" />
|
||||
<mxPoint x="-110" y="470" />
|
||||
<mxPoint x="-110" y="470" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="arch-6" parent="1" style="rounded=1;arcSize=3;whiteSpace=wrap;html=1;verticalAlign=top;align=left;spacingLeft=8;fontStyle=1;fillColor=#fafafa;strokeColor=#6c8ebf;" value="LibreDesk" vertex="1">
|
||||
<mxGeometry height="465" width="890" x="50" y="160" as="geometry" />
|
||||
<mxGeometry height="465" width="970" x="-30" y="160" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="HigBPHvGvvlsroYYhkdi-20" edge="1" parent="1" source="arch-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;endArrow=none;endFill=0;" target="arch-4">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
@@ -83,7 +83,7 @@
|
||||
<mxGeometry height="70" width="170" x="700" y="180" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="arch-11" parent="1" style="rounded=1;arcSize=3;whiteSpace=wrap;html=1;verticalAlign=top;align=left;spacingLeft=8;fontStyle=1;fillColor=#fafafa;strokeColor=#6c8ebf;" value="Tools <span style="font-weight:normal">(function calling: name + JSON schema, exposed to the LLM)</span>" vertex="1">
|
||||
<mxGeometry height="190" width="735" x="135" y="410" as="geometry" />
|
||||
<mxGeometry height="210" width="735" x="135" y="390" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="HigBPHvGvvlsroYYhkdi-16" edge="1" parent="1" source="arch-12" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;defaultLabelBackgroundColor=page;endArrow=none;endFill=0;" target="arch-8">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
@@ -123,16 +123,70 @@
|
||||
<mxCell id="fix-6" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;dashed=1;strokeWidth=2;" value="<b>REST API</b><br>GET /stations/{serial}/diagnostic?from=…&amp;to=…<br>→ events: family, start, end, evidence" vertex="1">
|
||||
<mxGeometry height="80" width="360" x="135" y="780" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-check" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="<b>Access check</b> (before any data is read)<br>same identity headers → access service:<br>serial among the customer's stations? no → 403" vertex="1">
|
||||
<mxGeometry height="70" width="360" x="135" y="880" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-allowed" edge="1" parent="1" source="acc-check" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="fix-7" value="allowed">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-tool" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="<b>get_customer_access()</b><br>no parameter: called first, on Generate reply" vertex="1">
|
||||
<mxGeometry height="62" width="320" x="155" y="432" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-e-conv" edge="1" parent="1" source="HigBPHvGvvlsroYYhkdi-3" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;" target="acc-tool" value="contact identity<br>(X-Libredesk-Contact-*<br>headers, added by<br>LibreDesk, not the LLM)">
|
||||
<mxGeometry relative="1" x="-0.1837" as="geometry">
|
||||
<mxPoint as="offset" />
|
||||
<Array as="points">
|
||||
<mxPoint x="40" y="260" />
|
||||
<mxPoint x="40" y="448" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="acc-svc" parent="1" style="rounded=1;arcSize=3;whiteSpace=wrap;html=1;verticalAlign=top;align=left;spacingLeft=8;fontStyle=1;fillColor=#fdf3f2;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="Access service (independent container)" vertex="1">
|
||||
<mxGeometry height="330" width="465" x="-390" y="740" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-api" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="<b>REST API</b><br>GET /customer/access (identity from the headers)<br>→ projects the customer may see: project, serial, role" vertex="1">
|
||||
<mxGeometry height="80" width="425" x="-370" y="780" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-lookup" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f8cecc;strokeColor=#b85450;dashed=1;strokeWidth=2;" value="<b>Rights lookup</b><br>contact e-mail → dashboard account (auth0|…)<br>→ its UserGroups (user / dev_admin) → Device.serial_number<br>unknown contact → empty list" vertex="1">
|
||||
<mxGeometry height="150" width="425" x="-370" y="890" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-e-api" edge="1" parent="1" source="acc-api" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;strokeWidth=2;exitX=0.5;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-lookup" value="">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-auth0" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#f5f5f5;strokeColor=#666666;" value="<b>utilisateurs.json</b><br>e-mail → auth0|…<br>exported once from Auth0" vertex="1">
|
||||
<mxGeometry height="70" width="200" x="-390" y="1190" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-db" parent="1" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=10;fillColor=#f8cecc;strokeColor=#b85450;" value="<b>Access rights</b> (dashboard DB)<br><b>UserGroupEntry</b>: user → UserGroup<br><b>UserGroup</b>: device × role (user · dev_admin)<br><b>Device</b>.serial_number (1..n per serial)" vertex="1">
|
||||
<mxGeometry height="120" width="245" x="-170" y="1165" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-e-auth0" edge="1" parent="1" source="acc-lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;exitX=0.2;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-auth0" value="e-mail → auth0|…">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-e-db" edge="1" parent="1" source="acc-lookup" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;exitX=0.75;exitY=1;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-db" value="read-only">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="acc-e-tool" edge="1" parent="1" source="acc-tool" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;strokeWidth=2;exitX=0;exitY=0.75;exitDx=0;exitDy=0;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" target="acc-api" value="HTTP GET<br>+ identity headers">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<Array as="points">
|
||||
<mxPoint x="100" y="478" />
|
||||
<mxPoint x="100" y="660" />
|
||||
<mxPoint x="-157" y="660" />
|
||||
</Array>
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
<mxCell id="acc-e-check" edge="1" parent="1" source="acc-check" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#b85450;dashed=1;fontColor=#b85450;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" target="acc-api" value="re-check:<br>the LLM cannot<br>widen access">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="fix-7" parent="1" style="rounded=1;whiteSpace=wrap;html=1;fillColor=#ffe6cc;strokeColor=#d79b00;dashed=1;strokeWidth=2;" value="<b>Detectors</b><br>visibility · obstruction · target issue<br>thermal · no data · displacement<br>→ classified events" vertex="1">
|
||||
<mxGeometry height="150" width="360" x="135" y="890" as="geometry" />
|
||||
<mxGeometry height="80" width="360" x="135" y="975" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="fix-8" parent="1" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=10;fillColor=#d5e8d4;strokeColor=#82b366;" value="<b>Station data</b> (AIMsight platform)" vertex="1">
|
||||
<mxGeometry height="70" width="360" x="135" y="1190" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="fix-10" edge="1" parent="1" source="arch-13" style="rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;edgeStyle=orthogonalEdgeStyle;" target="fix-6" value="7. HTTP GET (serial, from, to)">
|
||||
<mxCell id="fix-10" edge="1" parent="1" source="arch-13" style="rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;edgeStyle=orthogonalEdgeStyle;" target="fix-6" value="7. HTTP GET (serial, from, to)<br>+ identity headers">
|
||||
<mxGeometry relative="1" x="0.1306" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="fix-11" edge="1" parent="1" source="fix-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;exitX=0.500;exitY=1.000;exitDx=0;exitDy=0;entryX=0.500;entryY=0.000;entryDx=0;entryDy=0;" target="fix-7" value="">
|
||||
<mxCell id="fix-11" edge="1" parent="1" source="fix-6" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;exitX=0.500;exitY=1.000;exitDx=0;exitDy=0;entryX=0.500;entryY=0.000;entryDx=0;entryDy=0;" target="acc-check" value="">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="fix-12" edge="1" parent="1" source="fix-7" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#d79b00;strokeWidth=2;dashed=1;fontColor=#b36b00;exitX=0.500;exitY=1.000;exitDx=0;exitDy=0;entryX=0.500;entryY=0.000;entryDx=0;entryDy=0;" target="fix-8" value="reads the range (read-only)">
|
||||
@@ -140,7 +194,7 @@
|
||||
</mxCell>
|
||||
<mxCell id="gen-boundary" edge="1" parent="1" style="endArrow=none;html=1;rounded=0;dashed=1;dashPattern=8 4;strokeColor=#999999;strokeWidth=1;" value="">
|
||||
<mxGeometry relative="1" as="geometry">
|
||||
<mxPoint x="60" y="680" as="sourcePoint" />
|
||||
<mxPoint x="-400" y="680" as="sourcePoint" />
|
||||
<mxPoint x="1380" y="680" as="targetPoint" />
|
||||
</mxGeometry>
|
||||
</mxCell>
|
||||
@@ -177,8 +231,8 @@
|
||||
<mxCell id="gen-host-edge" edge="1" parent="1" source="gen-host" style="edgeStyle=orthogonalEdgeStyle;rounded=0;html=1;labelBackgroundColor=#ffffff;endArrow=classic;strokeColor=#999999;dashed=1;fontColor=#666666;exitX=0;exitY=0.5;exitDx=0;exitDy=0;entryX=1;entryY=0.5;entryDx=0;entryDy=0;" target="gen-6" value="HTTP">
|
||||
<mxGeometry relative="1" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="gen-legend" parent="1" style="shape=note;whiteSpace=wrap;html=1;size=14;align=left;verticalAlign=top;spacingLeft=10;spacingTop=6;spacingRight=8;fillColor=#fff2cc;strokeColor=#d6b656;" value="<b style="font-size:13px">Reusable mechanism</b><br><br><b>1. Host app</b> (here LibreDesk) triggers an action and sends context + tool list to the LLM.<br><b>2. Tool</b> = name + JSON schema + thin HTTP adapter. No business logic in the host.<br><b>3. Independent service</b> = container exposing a REST API; owns its domain logic and its data access, returns structured JSON.<br><b>4.</b> The LLM turns the tool result into the output (here a draft reviewed by a human).<br><br>New capability = one service + one tool declaration.<br>Same pattern for another host app (sales agent: CRM, quotes, stock…).<br><br><b>Legend</b><br><span style="color:#6c8ebf">■</span> existing LibreDesk<br><span style="color:#d79b00">■</span> dashed orange: this use case (planned)<br><span style="color:#9673a6">■</span> dashed purple: any other service, plugged the same way<br><span style="color:#999999">■</span> dashed grey: other consumers of the services" vertex="1">
|
||||
<mxGeometry height="380" width="380" x="1000" y="160" as="geometry" />
|
||||
<mxCell id="gen-legend" parent="1" style="shape=note;whiteSpace=wrap;html=1;size=14;align=left;verticalAlign=top;spacingLeft=10;spacingTop=6;spacingRight=8;fillColor=#fff2cc;strokeColor=#d6b656;" value="<b style="font-size:13px">Reusable mechanism</b><br><br><b>1. Host app</b> (here LibreDesk) triggers an action and sends context + tool list to the LLM.<br><b>2. Tool</b> = name + JSON schema + thin HTTP adapter. No business logic in the host.<br><b>3. Independent service</b> = container exposing a REST API; owns its domain logic and its data access, returns structured JSON.<br><b>4.</b> The LLM turns the tool result into the output (here a draft reviewed by a human).<br><b>5. Access</b>: on Generate reply the LLM first calls get_customer_access; LibreDesk adds the contact identity (headers), the access service returns the stations the customer may read (Auth0 export + UserGroup, the dashboard's rule). Each data service checks again with the same headers.<br><br>New capability = one service + one tool declaration.<br>Same pattern for another host app (sales agent: CRM, quotes, stock…).<br><br><b>Legend</b><br><span style="color:#6c8ebf">■</span> existing LibreDesk<br><span style="color:#d79b00">■</span> dashed orange: this use case (planned)<br><span style="color:#b85450">■</span> red: access rights (planned)<br><span style="color:#9673a6">■</span> dashed purple: any other service, plugged the same way<br><span style="color:#999999">■</span> dashed grey: other consumers of the services" vertex="1">
|
||||
<mxGeometry height="450" width="380" x="1000" y="160" as="geometry" />
|
||||
</mxCell>
|
||||
</root>
|
||||
</mxGraphModel>
|
||||
|
||||
Reference in new issue
Block a user