Skip to content

Commit baadd3b

Browse files
authored
Reach a server added by its address as the person the host app signed in (#2797)
* API: reach a server added by its address as the person the host app signed in replaceApp takes an optional hostToken, { tokenEndpoint, scope }: on a deployment with embedded sign-in, OpenBot swaps a short assertion about the signed-in person at the host app's token endpoint (RFC 7523 JWT bearer grant) and sends the access token it gets to the server. Absent keeps what the server has, and null takes it away, as entraScope does. An app answers hostTokenEndpoint and hostTokenScope, null on every server not reached this way. The bundle and the web app's generated client are regenerated. * Docs: calling an MCP server as the person the host app signed in A subsection of Embedded sign-in: the assertion OpenBot signs and where its key is published, the JWT bearer request it sends to the host's token endpoint, what it needs back, caching and re-checks, how an administrator sets it on a server with hostToken, and what refuses it. * Show a server reached through the host app as reached as the person asking, and say what the assertion's header and iat carry * Docs: OPENBOT_EMBED_HOST_TOKEN_KEY turns on calling an MCP server as the person * Docs and spec: only the host's own token endpoint, one spelling for aud and the call, nbf, and what the person reads for each answer * Docs and spec: scope in OAuth's grammar, loopback by address only, no nbf, a day's cache cap, and what the person reads when the host can't be reached or refuses * Docs and spec: a padded token endpoint is refused, not trimmed, the answer read up to 64 KiB, a 429 means try again, and what is refused before the host is asked * Say that a token endpoint is written in ASCII, and sharpen the host's key and clock rules * Show the host-token row in a real browser, and call the host one name everywhere Admin's page of a server reached through the app OpenBot is part of is now drawn in Chromium and WebKit (reached-as-the-person-browser.test.tsx, in the WebKit job's list, which runs both engines). It checks the Connection card's description, the "How this is reached" row's text, the token endpoint under it and its badge, beside the Entra server's page for comparison, light and dark, wide and on a phone. It fails against the previous copy and on main, where the row does not exist. The row's badge is now the token endpoint's host (auth.example.com) instead of "Host app", and the web app and the person-facing sentences in docs/configuration.md say "the app OpenBot is part of", the name the backend's refusals already use. The embedded sign-in section says once that the docs call it the host app. The card's description is split into two short sentences. The moved-apps.test.ts addition is dropped. needsNoAccountOfYours never reads hostTokenEndpoint, so the assertion restated the default for a server added by its address and passed with or without this change. There is no code here for it to guard; the browser test covers what changed.
1 parent d080200 commit baadd3b

16 files changed

Lines changed: 997 additions & 29 deletions

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,9 @@ jobs:
586586
# anything", wide and on a phone, light and dark.
587587
# And Audit's "Try a change" handing its action to What would happen by an all-digit handle: the
588588
# link, the page, a reload, and the bare address an older tab kept.
589+
# And Admin's page of an app added by its address and reached as the person asking: its "How this
590+
# is reached" row, through the app OpenBot is part of (named by its token endpoint's host) and
591+
# through Microsoft Entra, with no token to paste.
589592
# And Report a bug, Your bug reports and Admin's Bug reports, wide and on a phone, light and dark,
590593
# held against Add credential and the Vault: a file taken, one refused, the report saved. In the image, as above:
591594
# WebKit's system packages are about 94 MB, which took nine minutes from the mirror on a slow day.
@@ -716,6 +719,7 @@ jobs:
716719
app/tests/plan-notices-layout.test.tsx
717720
app/tests/question-answer-prompt-browser.test.tsx
718721
app/tests/queue-send-now-layout.test.tsx
722+
app/tests/reached-as-the-person-browser.test.tsx
719723
app/tests/rejoin-fresh-token-browser.test.tsx
720724
app/tests/renderer-crash.test.ts
721725
app/tests/renewal-keeps-typing-browser.test.tsx

‎api/openapi.yaml‎

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6619,7 +6619,7 @@ paths:
66196619
- Apps
66206620
operationId: replaceApp
66216621
summary: Add or replace a server at a chosen id
6622-
description: Add a server by its address at an id an administrator chooses, or replace the server at that id. It is for pointing OpenBot at a server of the organization's own, such as one reached as the signed-in person through Microsoft Entra ID (entraScope). Unlike createApp, it doesn't ask the server how it is reached and doesn't check the MCP allowlist. The id is 2 to 40 lower-case letters, numbers and hyphens, and can't be a catalogue entry's, a screen's, or one kept for apps from the directory. credentialId names a vault credential (createCredential) the server is reached with. An absent entraScope keeps the one the server has, and null takes it away. Recorded on the audit trail. Answers the server, whether it was added or replaced. Only an administrator may.
6622+
description: Add a server by its address at an id an administrator chooses, or replace the server at that id. It is for pointing OpenBot at a server of the organization's own, such as one reached as the signed-in person through Microsoft Entra ID (entraScope), or one reached as the signed-in person through the host app that signs them in (hostToken). Unlike createApp, it doesn't ask the server how it is reached and doesn't check the MCP allowlist. The id is 2 to 40 lower-case letters, numbers and hyphens, and can't be a catalogue entry's, a screen's, or one kept for apps from the directory. credentialId names a vault credential (createCredential) the server is reached with. An absent entraScope or hostToken keeps the one the server has, and null takes it away. Recorded on the audit trail. Answers the server, whether it was added or replaced. Only an administrator may.
66236623
security:
66246624
- webSession: []
66256625
- appOAuth:
@@ -6640,6 +6640,14 @@ paths:
66406640
title: HR
66416641
url: https://hr.example.com/mcp
66426642
entraScope: api://hr-api/.default
6643+
hostApp:
6644+
summary: A server reached as the person the host app signed in.
6645+
value:
6646+
title: Orders
6647+
url: https://orders.example.com/mcp
6648+
hostToken:
6649+
tokenEndpoint: https://auth.example.com/oauth/token
6650+
scope: orders:read
66436651
key:
66446652
summary: A server reached with a vault credential.
66456653
value:
@@ -35646,6 +35654,8 @@ components:
3564635654
- dynamicClient
3564735655
- signIn
3564835656
- entraScope
35657+
- hostTokenEndpoint
35658+
- hostTokenScope
3564935659
- accountMode
3565035660
- sharedAccountConnected
3565135661
- sharedOnly
@@ -35712,6 +35722,16 @@ components:
3571235722
- string
3571335723
- 'null'
3571435724
description: The Microsoft Entra ID scope a server is reached with as the signed-in person, or null when it is reached with its own key.
35725+
hostTokenEndpoint:
35726+
type:
35727+
- string
35728+
- 'null'
35729+
description: 'The token endpoint of the host app that signs people in, where a server is reached as the signed-in person: OpenBot swaps an assertion about the person for an access token there (hostToken on replaceApp). Null when the server isn''t reached this way.'
35730+
hostTokenScope:
35731+
type:
35732+
- string
35733+
- 'null'
35734+
description: The scope OpenBot asks hostTokenEndpoint for, or null when it asks for none or the server isn't reached through a host app.
3571535735
accountMode:
3571635736
oneOf:
3571735737
- $ref: '#/components/schemas/AppAccountMode'
@@ -35872,6 +35892,27 @@ components:
3587235892
type: string
3587335893
minLength: 1
3587435894
description: The app already here.
35895+
AppHostToken:
35896+
type: object
35897+
additionalProperties: false
35898+
required:
35899+
- tokenEndpoint
35900+
description: Where OpenBot swaps an assertion about the signed-in person for an access token to the server, with the JWT bearer grant (RFC 7523).
35901+
properties:
35902+
tokenEndpoint:
35903+
type: string
35904+
minLength: 1
35905+
maxLength: 2048
35906+
pattern: ^\S+$
35907+
description: 'The host app''s token endpoint: on the same origin as the deployment''s embedded sign-in issuer, or one the deployment lists in OPENBOT_EMBED_HOST_TOKEN_ENDPOINTS. HTTPS; plain HTTP only on 127.0.0.1 or [::1] (never localhost), where the deployment allows loopback servers. Kept and answered in its normalized spelling, which is also the assertion''s audience. No user, password, fragment, backslash or space, spaces around it included: an endpoint with a space or newline before or after it is refused, not trimmed. Written in ASCII: an endpoint with any other character in it (a zero-width space, a soft hyphen, fullwidth letters, 。, an accented letter in the path) is refused, not rewritten; write an internationalized host in its xn-- form and percent-encode anything else. So is one whose host a URL parser would read as another host (percent-encoded, or a short IPv4 form like 127.1).'
35908+
scope:
35909+
type:
35910+
- string
35911+
- 'null'
35912+
minLength: 1
35913+
maxLength: 1024
35914+
pattern: ^[!#-\[\]-~]+( [!#-\[\]-~]+)*$
35915+
description: 'The scope to ask the token endpoint for, sent as scope: words of printable ASCII, with no quotes, backslashes or spaces in them, separated by single spaces (RFC 6749 §3.3). Null or absent asks for none.'
3587535916
ReplaceAppRequest:
3587635917
type: object
3587735918
additionalProperties: false
@@ -35905,6 +35946,11 @@ components:
3590535946
maxLength: 256
3590635947
pattern: ^\S+$
3590735948
description: One Microsoft Entra ID scope, such as api://hr-api/.default, to reach the server with as the signed-in person. It needs Microsoft sign-in set up, and takes no credentialId. Null reaches the server with its credential again; absent keeps what the server has.
35949+
hostToken:
35950+
oneOf:
35951+
- $ref: '#/components/schemas/AppHostToken'
35952+
- type: 'null'
35953+
description: 'Reach the server as the signed-in person through the host app that signs them in (embedded sign-in). For each person, OpenBot signs a short assertion about them and swaps it at the host app''s token endpoint for an access token, which it sends to the server as Authorization: Bearer. It needs embedded sign-in set up, and takes no credentialId, entraScope or tokenHeader, and no sign-in of the server''s own. An organization that requires single sign-on refuses it, as it refuses entraScope. Null takes it away; absent keeps what the server has. Needs OPENBOT_EMBED_HOST_TOKEN_KEY set on the deployment. Where the deployment no longer has embedded sign-in or OPENBOT_EMBED_HOST_TOKEN_KEY, a server already marked can still be replaced by sending hostToken as null.'
3590835954
tokenHeader:
3590935955
type:
3591035956
- string
@@ -60744,6 +60790,8 @@ components:
6074460790
dynamicClient: false
6074560791
signIn: true
6074660792
entraScope: null
60793+
hostTokenEndpoint: null
60794+
hostTokenScope: null
6074760795
accountMode: null
6074860796
sharedAccountConnected: false
6074960797
sharedOnly: false
@@ -60770,6 +60818,8 @@ components:
6077060818
dynamicClient: false
6077160819
signIn: false
6077260820
entraScope: null
60821+
hostTokenEndpoint: null
60822+
hostTokenScope: null
6077360823
accountMode: null
6077460824
sharedAccountConnected: false
6077560825
sharedOnly: false
@@ -60806,6 +60856,8 @@ components:
6080660856
dynamicClient: false
6080760857
signIn: true
6080860858
entraScope: null
60859+
hostTokenEndpoint: null
60860+
hostTokenScope: null
6080960861
accountMode: null
6081060862
sharedAccountConnected: false
6081160863
sharedOnly: false
@@ -60865,6 +60917,8 @@ components:
6086560917
dynamicClient: false
6086660918
signIn: false
6086760919
entraScope: null
60920+
hostTokenEndpoint: null
60921+
hostTokenScope: null
6086860922
accountMode: null
6086960923
sharedAccountConnected: false
6087060924
sharedOnly: false

‎api/openapi/apps.yaml‎

Lines changed: 95 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,13 +214,15 @@ paths:
214214
Add a server by its address at an id an administrator chooses, or
215215
replace the server at that id. It is for pointing OpenBot at a server
216216
of the organization's own, such as one reached as the signed-in person
217-
through Microsoft Entra ID (entraScope). Unlike createApp, it doesn't
218-
ask the server how it is reached and doesn't check the MCP allowlist.
219-
The id is 2 to 40 lower-case letters, numbers and hyphens, and can't
220-
be a catalogue entry's, a screen's, or one kept for apps from the
221-
directory. credentialId names a vault credential (createCredential)
222-
the server is reached with. An absent entraScope keeps the one the
223-
server has, and null takes it away. Recorded on the audit trail.
217+
through Microsoft Entra ID (entraScope), or one reached as the
218+
signed-in person through the host app that signs them in (hostToken).
219+
Unlike createApp, it doesn't ask the server how it is reached and
220+
doesn't check the MCP allowlist. The id is 2 to 40 lower-case letters,
221+
numbers and hyphens, and can't be a catalogue entry's, a screen's, or
222+
one kept for apps from the directory. credentialId names a vault
223+
credential (createCredential) the server is reached with. An absent
224+
entraScope or hostToken keeps the one the server has, and null takes
225+
it away. Recorded on the audit trail.
224226
Answers the server, whether it was added or replaced. Only an
225227
administrator may.
226228
security:
@@ -242,6 +244,14 @@ paths:
242244
title: HR
243245
url: https://hr.example.com/mcp
244246
entraScope: api://hr-api/.default
247+
hostApp:
248+
summary: A server reached as the person the host app signed in.
249+
value:
250+
title: Orders
251+
url: https://orders.example.com/mcp
252+
hostToken:
253+
tokenEndpoint: https://auth.example.com/oauth/token
254+
scope: orders:read
245255
key:
246256
summary: A server reached with a vault credential.
247257
value:
@@ -921,6 +931,8 @@ components:
921931
- dynamicClient
922932
- signIn
923933
- entraScope
934+
- hostTokenEndpoint
935+
- hostTokenScope
924936
- accountMode
925937
- sharedAccountConnected
926938
- sharedOnly
@@ -992,6 +1004,18 @@ components:
9921004
description: >-
9931005
The Microsoft Entra ID scope a server is reached with as the
9941006
signed-in person, or null when it is reached with its own key.
1007+
hostTokenEndpoint:
1008+
type: [string, 'null']
1009+
description: >-
1010+
The token endpoint of the host app that signs people in, where a
1011+
server is reached as the signed-in person: OpenBot swaps an
1012+
assertion about the person for an access token there (hostToken
1013+
on replaceApp). Null when the server isn't reached this way.
1014+
hostTokenScope:
1015+
type: [string, 'null']
1016+
description: >-
1017+
The scope OpenBot asks hostTokenEndpoint for, or null when it asks
1018+
for none or the server isn't reached through a host app.
9951019
accountMode:
9961020
oneOf:
9971021
- $ref: '#/components/schemas/AppAccountMode'
@@ -1199,6 +1223,23 @@ components:
11991223
reach the server with as the signed-in person. It needs Microsoft
12001224
sign-in set up, and takes no credentialId. Null reaches the server
12011225
with its credential again; absent keeps what the server has.
1226+
hostToken:
1227+
oneOf:
1228+
- $ref: '#/components/schemas/AppHostToken'
1229+
- type: 'null'
1230+
description: >-
1231+
Reach the server as the signed-in person through the host app that
1232+
signs them in (embedded sign-in). For each person, OpenBot signs a
1233+
short assertion about them and swaps it at the host app's token
1234+
endpoint for an access token, which it sends to the server as
1235+
Authorization: Bearer. It needs embedded sign-in set up, and takes
1236+
no credentialId, entraScope or tokenHeader, and no sign-in of the
1237+
server's own. An organization that requires single sign-on refuses
1238+
it, as it refuses entraScope. Null takes it away; absent keeps
1239+
what the server has. Needs OPENBOT_EMBED_HOST_TOKEN_KEY set on the
1240+
deployment. Where the deployment no longer has embedded sign-in or
1241+
OPENBOT_EMBED_HOST_TOKEN_KEY, a server already marked can still be
1242+
replaced by sending hostToken as null.
12021243
tokenHeader:
12031244
type: [string, 'null']
12041245
minLength: 1
@@ -1211,6 +1252,45 @@ components:
12111252
HTTP itself uses (Host, Content-Length, Cookie, Connection,
12121253
Transfer-Encoding and the like) is refused. Null sends the key as
12131254
Authorization: Bearer again; absent keeps what the server has.
1255+
AppHostToken:
1256+
type: object
1257+
additionalProperties: false
1258+
required: [tokenEndpoint]
1259+
description: >-
1260+
Where OpenBot swaps an assertion about the signed-in person for an
1261+
access token to the server, with the JWT bearer grant (RFC 7523).
1262+
properties:
1263+
tokenEndpoint:
1264+
type: string
1265+
minLength: 1
1266+
maxLength: 2048
1267+
pattern: ^\S+$
1268+
description: >-
1269+
The host app's token endpoint: on the same origin as the
1270+
deployment's embedded sign-in issuer, or one the deployment lists
1271+
in OPENBOT_EMBED_HOST_TOKEN_ENDPOINTS. HTTPS; plain HTTP only on
1272+
127.0.0.1 or [::1] (never localhost), where the deployment allows
1273+
loopback servers. Kept and answered in its normalized spelling,
1274+
which is also the assertion's audience. No user, password,
1275+
fragment, backslash or space, spaces around it included: an
1276+
endpoint with a space or newline before or after it is refused,
1277+
not trimmed. Written in ASCII: an endpoint with any other
1278+
character in it (a zero-width space, a soft hyphen, fullwidth
1279+
letters, 。, an accented letter in the path) is refused, not
1280+
rewritten; write an internationalized host in its xn-- form and
1281+
percent-encode anything else. So is one whose host a URL parser
1282+
would read as another host (percent-encoded, or a short IPv4 form
1283+
like 127.1).
1284+
scope:
1285+
type: [string, 'null']
1286+
minLength: 1
1287+
maxLength: 1024
1288+
pattern: '^[!#-\[\]-~]+( [!#-\[\]-~]+)*$'
1289+
description: >-
1290+
The scope to ask the token endpoint for, sent as scope: words of
1291+
printable ASCII, with no quotes, backslashes or spaces in them,
1292+
separated by single spaces (RFC 6749 §3.3). Null or absent asks
1293+
for none.
12141294
UpdateAppRequest:
12151295
type: object
12161296
additionalProperties: false
@@ -1897,6 +1977,8 @@ components:
18971977
dynamicClient: false
18981978
signIn: false
18991979
entraScope: null
1980+
hostTokenEndpoint: null
1981+
hostTokenScope: null
19001982
accountMode: null
19011983
sharedAccountConnected: false
19021984
sharedOnly: false
@@ -1933,6 +2015,8 @@ components:
19332015
dynamicClient: false
19342016
signIn: true
19352017
entraScope: null
2018+
hostTokenEndpoint: null
2019+
hostTokenScope: null
19362020
accountMode: null
19372021
sharedAccountConnected: false
19382022
sharedOnly: false
@@ -1969,6 +2053,8 @@ components:
19692053
dynamicClient: false
19702054
signIn: true
19712055
entraScope: null
2056+
hostTokenEndpoint: null
2057+
hostTokenScope: null
19722058
accountMode: null
19732059
sharedAccountConnected: false
19742060
sharedOnly: false
@@ -1995,6 +2081,8 @@ components:
19952081
dynamicClient: false
19962082
signIn: false
19972083
entraScope: null
2084+
hostTokenEndpoint: null
2085+
hostTokenScope: null
19982086
accountMode: null
19992087
sharedAccountConnected: false
20002088
sharedOnly: false

0 commit comments

Comments
 (0)