[{"data":1,"prerenderedAt":3407},["ShallowReactive",2],{"navigation":3,"\u002Fguides\u002Fmcp-server-oauth":237,"\u002Fguides\u002Fmcp-server-oauth-surround":3402},[4,43,119,127,211],{"title":5,"path":6,"stem":7,"children":8,"icon":42},"Get started","\u002Fgetting-started","1.getting-started\u002F1.index",[9,12,17,22,27,32,37],{"title":10,"path":6,"stem":7,"icon":11},"Introduction","i-lucide-house",{"title":13,"path":14,"stem":15,"icon":16},"Install","\u002Fgetting-started\u002Finstallation","1.getting-started\u002F2.installation","i-lucide-download",{"title":18,"path":19,"stem":20,"icon":21},"Quick start","\u002Fgetting-started\u002Fquick-start","1.getting-started\u002F3.quick-start","i-lucide-play",{"title":23,"path":24,"stem":25,"icon":26},"Choose your setup","\u002Fgetting-started\u002Fchoose-a-sign-in-stack","1.getting-started\u002F4.choose-a-sign-in-stack","i-lucide-signpost",{"title":28,"path":29,"stem":30,"icon":31},"Browser clients","\u002Fgetting-started\u002Fbrowser-clients","1.getting-started\u002F5.browser-clients","i-lucide-globe",{"title":33,"path":34,"stem":35,"icon":36},"Coding agents","\u002Fgetting-started\u002Fai-agents","1.getting-started\u002F6.ai-agents","i-lucide-bot",{"title":38,"path":39,"stem":40,"icon":41},"Upgrade from 3.x","\u002Fgetting-started\u002Fupgrading-to-4","1.getting-started\u002F8.upgrading-to-4","i-lucide-arrow-up-right","i-lucide-rocket",{"title":44,"icon":45,"path":46,"stem":47,"children":48,"page":118},"Guides","i-lucide-waypoints","\u002Fguides","2.guides",[49,54,59,64,69,74,79,84,89,94,99,104,109,114],{"title":50,"path":51,"stem":52,"icon":53},"Register users","\u002Fguides\u002Fregistration","2.guides\u002F02.registration","i-lucide-user-plus",{"title":55,"path":56,"stem":57,"icon":58},"Sign users in","\u002Fguides\u002Fsign-in","2.guides\u002F03.sign-in","i-lucide-log-in",{"title":60,"path":61,"stem":62,"icon":63},"Sign users out","\u002Fguides\u002Fsign-out","2.guides\u002F04.sign-out","i-lucide-log-out",{"title":65,"path":66,"stem":67,"icon":68},"Two-factor auth","\u002Fguides\u002Ftwo-factor","2.guides\u002F05.two-factor","i-lucide-smartphone",{"title":70,"path":71,"stem":72,"icon":73},"Email-code sign-in","\u002Fguides\u002Femail-code","2.guides\u002F06.email-code","i-lucide-mail",{"title":75,"path":76,"stem":77,"icon":78},"Reset a password","\u002Fguides\u002Freset-password","2.guides\u002F07.reset-password","i-lucide-key-round",{"title":80,"path":81,"stem":82,"icon":83},"Manage account","\u002Fguides\u002Fmanage-account","2.guides\u002F08.manage-account","i-lucide-user-cog",{"title":85,"path":86,"stem":87,"icon":88},"Manage passkeys","\u002Fguides\u002Fmanage-passkeys","2.guides\u002F09.manage-passkeys","i-lucide-scan-face",{"title":90,"path":91,"stem":92,"icon":93},"Link accounts","\u002Fguides\u002Flink-external-accounts","2.guides\u002F10.link-external-accounts","i-lucide-link",{"title":95,"path":96,"stem":97,"icon":98},"Require step-up","\u002Fguides\u002Fstep-up","2.guides\u002F11.step-up","i-lucide-shield-check",{"title":100,"path":101,"stem":102,"icon":103},"No public sign-up","\u002Fguides\u002Finternal-app","2.guides\u002F12.internal-app","i-lucide-building-2",{"title":105,"path":106,"stem":107,"icon":108},"List and revoke signed-in sessions","\u002Fguides\u002Factive-sessions","2.guides\u002F13.active-sessions","i-lucide-monitor-smartphone",{"title":110,"path":111,"stem":112,"icon":113},"MCP server with OAuth","\u002Fguides\u002Fmcp-server-oauth","2.guides\u002F14.mcp-server-oauth","i-lucide-plug-zap",{"title":115,"path":116,"stem":117,"icon":103},"Host context on OAuth grants","\u002Fguides\u002Foauth-grant-context","2.guides\u002F15.oauth-grant-context",false,{"title":120,"path":121,"stem":122,"children":123,"icon":126},"Composables","\u002Fcomposables","3.composables\u002F1.index",[124],{"title":125,"path":121,"stem":122,"icon":126},"Build a custom stack","i-lucide-blocks",{"title":128,"icon":129,"path":130,"stem":131,"children":132,"page":118},"Reference","i-lucide-book-open","\u002Fmodules","4.modules",[133,138,142,147,151,156,161,166,170,175,179,184,188,193,198,202,206],{"title":134,"path":135,"stem":136,"icon":137},"Endpoint reference","\u002Fmodules\u002Fendpoints","4.modules\u002F01.endpoints","i-lucide-route",{"title":139,"path":140,"stem":141,"icon":78},"Password auth","\u002Fmodules\u002Fpassword-auth","4.modules\u002F02.password-auth",{"title":143,"path":144,"stem":145,"icon":146},"Composition table","\u002Fmodules\u002Fcomposition","4.modules\u002F03.composition","i-lucide-table",{"title":148,"path":149,"stem":150,"icon":83},"Identity module","\u002Fmodules\u002Fidentity-management","4.modules\u002F04.identity-management",{"title":152,"path":153,"stem":154,"icon":155},"Cookie sign-in","\u002Fmodules\u002Fcookie-auth","4.modules\u002F05.cookie-auth","i-lucide-cookie",{"title":157,"path":158,"stem":159,"icon":160},"Identity bearer","\u002Fmodules\u002Fbearer-auth","4.modules\u002F06.bearer-auth","i-lucide-key",{"title":162,"path":163,"stem":164,"icon":165},"JWT","\u002Fmodules\u002Fjwt","4.modules\u002F07.jwt","i-lucide-fingerprint",{"title":167,"path":168,"stem":169,"icon":88},"Passkeys","\u002Fmodules\u002Fpasskeys","4.modules\u002F08.passkeys",{"title":171,"path":172,"stem":173,"icon":174},"Step-up ReAuth","\u002Fmodules\u002Freauth","4.modules\u002F09.reauth","i-lucide-shield-alert",{"title":176,"path":177,"stem":178,"icon":58},"External OAuth","\u002Fmodules\u002Fexternal-oauth","4.modules\u002F10.external-oauth",{"title":180,"path":181,"stem":182,"icon":183},"Configuration","\u002Fmodules\u002Fconfiguration","4.modules\u002F11.configuration","i-lucide-settings",{"title":185,"path":186,"stem":187,"icon":98},"CSRF rules","\u002Fmodules\u002Fcsrf","4.modules\u002F12.csrf",{"title":189,"path":190,"stem":191,"icon":192},"Responses","\u002Fmodules\u002Ferrors","4.modules\u002F13.errors","i-lucide-circle-alert",{"title":194,"path":195,"stem":196,"icon":197},"Rate-limit policies","\u002Fmodules\u002Frate-limits","4.modules\u002F14.rate-limits","i-lucide-gauge",{"title":199,"path":200,"stem":201,"icon":73},"Email codes","\u002Fmodules\u002Femail-code","4.modules\u002F15.email-code",{"title":203,"path":204,"stem":205,"icon":78},"OAuth server","\u002Fmodules\u002Fopeniddict","4.modules\u002F16.openiddict",{"title":207,"path":208,"stem":209,"icon":210},"People and agents","\u002Fmodules\u002Fcallers","4.modules\u002F17.callers","i-lucide-user-check",{"title":212,"icon":213,"path":214,"stem":215,"children":216,"page":118},"Concepts","i-lucide-lightbulb","\u002Fconcepts","5.concepts",[217,222,227,232],{"title":218,"path":219,"stem":220,"icon":221},"Comparison","\u002Fconcepts\u002Fcompare","5.concepts\u002F1.compare","i-lucide-git-compare",{"title":223,"path":224,"stem":225,"icon":226},"Security model","\u002Fconcepts\u002Fsecurity-model","5.concepts\u002F2.security-model","i-lucide-shield",{"title":228,"path":229,"stem":230,"icon":231},"Production","\u002Fconcepts\u002Fproduction","5.concepts\u002F3.production","i-lucide-factory",{"title":233,"path":234,"stem":235,"icon":236},"FAQ","\u002Fconcepts\u002Ffaq","5.concepts\u002F4.faq","i-lucide-circle-help",{"id":238,"title":239,"body":240,"description":3395,"extension":3396,"faq":118,"links":3397,"meta":3398,"navigation":3399,"path":111,"seo":3400,"stem":112,"__hash__":3401},"docs\u002F2.guides\u002F14.mcp-server-oauth.md","Expose an MCP server with per-user OAuth",{"type":241,"value":242,"toc":3377},"minimark",[243,247,261,266,333,458,462,492,523,536,540,1284,1293,1298,1304,1590,1608,1612,1615,1675,1689,1693,1764,1784,1788,1866,1895,1899,1908,2070,2075,2088,2312,2335,2338,2342,2348,2523,2556,2560,2569,2580,2944,2989,2996,3000,3003,3094,3107,3111,3131,3134,3262,3268,3275,3279,3354,3358,3365,3373],[244,245,246],"p",{},"This guide connects an AI assistant, or any other MCP client, to a remote MCP server that your app hosts. Each person signs in as themselves. The assistant's token acts with that person's roles, and only within the scopes they approved. Your existing authorization policies keep working.",[244,248,249,250,254,255,260],{},"It uses the ",[251,252,253],"code",{},"AuthEndpoints.OpenIddict"," package (preview). The same steps work for a plain HTTP API that OAuth clients call. For every option, see the ",[256,257,259],"a",{"href":258},"https:\u002F\u002Fgithub.com\u002Fmadeyoga\u002FAuthEndpoints\u002Ftree\u002Fmain\u002Fsrc\u002FAuthEndpoints.OpenIddict#readme","package README",".",[262,263,265],"h2",{"id":264},"how-the-connection-works","How the connection works",[267,268,269,277,292,307,314,317,327,330],"ol",{},[270,271,272,273,276],"li",{},"The person pastes your MCP URL, for example ",[251,274,275],{},"https:\u002F\u002Fapp.example.com\u002Fmcp",", into the assistant.",[270,278,279,280,283,284,287,288,291],{},"The assistant calls ",[251,281,282],{},"\u002Fmcp"," without a token. It gets ",[251,285,286],{},"401"," with ",[251,289,290],{},"WWW-Authenticate: Bearer resource_metadata=\"https:\u002F\u002Fapp.example.com\u002F.well-known\u002Foauth-protected-resource\u002Fmcp\"",", reads that protected resource metadata (RFC 9728), and finds your authorization server.",[270,293,294,295,298,299,302,303,306],{},"The assistant identifies itself. It either uses an ",[251,296,297],{},"https"," URL as its ",[251,300,301],{},"client_id"," (a client ID metadata document, which the MCP spec prefers), or registers at ",[251,304,305],{},"\u002Fconnect\u002Fregister"," (dynamic client registration, the fallback).",[270,308,309,310,313],{},"The browser goes to ",[251,311,312],{},"\u002Fconnect\u002Fauthorize",". A signed-out person is sent to your sign-in page first. An existing session skips that step.",[270,315,316],{},"Your consent page shows the assistant's name, the domain that published it, and the requested scopes in words. The person approves or denies.",[270,318,319,320,323,324,326],{},"The assistant exchanges the code with PKCE and a ",[251,321,322],{},"resource"," indicator (RFC 8707) for an access token whose audience is ",[251,325,282],{},", plus a refresh token that rotates on every use.",[270,328,329],{},"Each MCP call runs as that person: your role and policy checks apply, narrowed by the granted scopes.",[270,331,332],{},"To disconnect the assistant, you revoke its authorization. To disconnect everything, you change the person's security stamp.",[334,335,336,349],"table",{},[337,338,339],"thead",{},[340,341,342,346],"tr",{},[343,344,345],"th",{},"Step",[343,347,348],{},"Feature",[350,351,352,367,383,400,414,436],"tbody",{},[340,353,354,358],{},[355,356,357],"td",{},"2",[355,359,360,363,364],{},[251,361,362],{},"ProtectedResource",", ",[251,365,366],{},"UseOAuthResourceChallenge()",[340,368,369,372],{},[355,370,371],{},"3",[355,373,374,363,377,363,380],{},[251,375,376],{},"ClientMetadataDocuments",[251,378,379],{},"DynamicRegistration",[251,381,382],{},"DynamicRegistration.AllowedScopes",[340,384,385,388],{},[355,386,387],{},"4–5",[355,389,390,363,393,396,397],{},[251,391,392],{},"LoginUrl",[251,394,395],{},"ConsentUrl",", the consent API, ",[251,398,399],{},"ScopeDefinitions",[340,401,402,405],{},[355,403,404],{},"6",[355,406,407,363,410,413],{},[251,408,409],{},"AdditionalResources",[251,411,412],{},"AcceptedAudiences",", rotating refresh tokens",[340,415,416,419],{},[355,417,418],{},"7",[355,420,421,363,424,363,427,363,430,363,433],{},[251,422,423],{},"RequireOAuthAudience",[251,425,426],{},"RequireOAuthScope",[251,428,429],{},"RequireOAuthScopeWhenDelegated",[251,431,432],{},"HasOAuthScope",[251,434,435],{},"AccessTokenClaims",[340,437,438,441],{},[355,439,440],{},"8",[355,442,443,444,447,448,451,452,363,455],{},"Connected apps (",[251,445,446],{},"GET","\u002F",[251,449,450],{},"DELETE \u002Foauth\u002Fauthorizations","), ",[251,453,454],{},"IOAuthConnectedAppService",[251,456,457],{},"UserManager.UpdateSecurityStampAsync",[262,459,461],{"id":460},"before-you-start","Before you start",[463,464,465,472,485],"ul",{},[270,466,467,468,471],{},"Your app signs people in with AuthEndpoints and an Identity cookie (",[251,469,470],{},"AddPasswordAuth",", or another setup that ends with the Identity application cookie). The authorize step reads that cookie.",[270,473,474,475,363,477,480,481,484],{},"Your app serves HTTPS on a public host. MCP clients reach ",[251,476,282],{},[251,478,479],{},"\u002F.well-known\u002F…",", and ",[251,482,483],{},"\u002Fconnect\u002F…"," on it.",[270,486,487,488,491],{},"To reuse role checks, Identity has roles (",[251,489,490],{},"AddRoles\u003CIdentityRole>()",").",[493,494,499],"pre",{"className":495,"code":496,"language":497,"meta":498,"style":498},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","dotnet add package AuthEndpoints.OpenIddict --prerelease\n","bash","",[251,500,501],{"__ignoreMap":498},[502,503,506,510,514,517,520],"span",{"class":504,"line":505},"line",1,[502,507,509],{"class":508},"sBMFI","dotnet",[502,511,513],{"class":512},"sfazB"," add",[502,515,516],{"class":512}," package",[502,518,519],{"class":512}," AuthEndpoints.OpenIddict",[502,521,522],{"class":512}," --prerelease\n",[244,524,525,526,529,530,532,533,260],{},"In this guide, one app serves both the cookie-authenticated API at ",[251,527,528],{},"\u002Fapi"," and the MCP server at ",[251,531,282],{},", at ",[251,534,535],{},"https:\u002F\u002Fapp.example.com",[262,537,539],{"id":538},"_1-register-the-authorization-server","1. Register the authorization server",[493,541,545],{"className":542,"code":543,"language":544,"meta":498,"style":498},"language-csharp shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","using AuthEndpoints.OpenIddict;\n\nbuilder.Services.AddOAuthServer\u003CAppUser, AppDbContext>(options =>\n{\n    options.Issuer = new Uri(\"https:\u002F\u002Fapp.example.com\u002F\");\n\n    \u002F\u002F Two resources on this host. A token is for one of them and is accepted only there.\n    options.Audience = \"https:\u002F\u002Fapp.example.com\u002Fapi\";\n    options.AdditionalResources.Add(\"https:\u002F\u002Fapp.example.com\u002Fmcp\");\n    options.AcceptedAudiences.Add(\"https:\u002F\u002Fapp.example.com\u002Fmcp\");\n\n    \u002F\u002F What a person can let an assistant do for them.\n    options.Scopes.Add(\"mcp\");\n    options.Scopes.Add(\"reports.read\");\n    options.Scopes.Add(\"account\"); \u002F\u002F your own first-party clients only\n\n    options.LoginUrl = \"https:\u002F\u002Fapp.example.com\u002Fsign-in\";\n    options.ConsentUrl = \"https:\u002F\u002Fapp.example.com\u002Foauth\u002Fconsent\";\n    options.Certificates.Path = \"\u002Fvar\u002Flib\u002Fmyapp\u002Foauth-keys\";\n\n    \u002F\u002F Assistants identify themselves with a metadata document, or register as a fallback.\n    options.ClientMetadataDocuments.Enabled = true;\n    options.DynamicRegistration.Enabled = true;\n    \u002F\u002F Clients that anyone can bring may hold only these scopes (plus offline_access).\n    options.DynamicRegistration.AllowedScopes.Add(\"mcp\");\n    options.DynamicRegistration.AllowedScopes.Add(\"reports.read\");\n\n    \u002F\u002F Discovery: one RFC 9728 document per resource, and a 401 that points at it.\n    options.ProtectedResource.Enabled = true;\n    options.ProtectedResource.ResourceName = \"Example API\";\n    options.ProtectedResource.ChallengePaths.Add(\"\u002Fapi\");\n    options.ProtectedResource.Resources.Add(new OAuthProtectedResourceDefinition\n    {\n        Resource = \"https:\u002F\u002Fapp.example.com\u002Fmcp\",\n        ResourceName = \"Example MCP server\",\n        Scopes = { \"mcp\", \"reports.read\" },\n        ChallengePaths = { \"\u002Fmcp\" },\n    });\n\n    \u002F\u002F Tokens carry the person's roles and user id, so existing checks work.\n    options.AccessTokenClaims.Roles = true;\n    options.AccessTokenClaims.UserId = true;\n})\n.BindConfiguration(\"OAuthServer\"); \u002F\u002F scope descriptions and host lists can live in appsettings\n","csharp",[251,546,547,566,573,611,617,651,656,663,685,709,732,737,743,768,792,820,825,846,867,893,898,904,926,945,951,979,1006,1011,1017,1036,1061,1089,1113,1119,1136,1153,1181,1199,1205,1210,1216,1236,1256,1262],{"__ignoreMap":498},[502,548,549,553,557,560,563],{"class":504,"line":505},[502,550,552],{"class":551},"sbssI","using",[502,554,556],{"class":555},"sTEyZ"," AuthEndpoints",[502,558,260],{"class":559},"sMK4o",[502,561,562],{"class":555},"OpenIddict",[502,564,565],{"class":559},";\n",[502,567,569],{"class":504,"line":568},2,[502,570,572],{"emptyLinePlaceholder":571},true,"\n",[502,574,576,579,581,584,586,590,593,596,599,602,605,608],{"class":504,"line":575},3,[502,577,578],{"class":555},"builder",[502,580,260],{"class":559},[502,582,583],{"class":555},"Services",[502,585,260],{"class":559},[502,587,589],{"class":588},"s2Zo4","AddOAuthServer",[502,591,592],{"class":559},"\u003C",[502,594,595],{"class":508},"AppUser",[502,597,598],{"class":559},",",[502,600,601],{"class":508}," AppDbContext",[502,603,604],{"class":559},">(",[502,606,607],{"class":508},"options",[502,609,610],{"class":559}," =>\n",[502,612,614],{"class":504,"line":613},4,[502,615,616],{"class":559},"{\n",[502,618,620,623,625,628,631,634,637,640,643,646,648],{"class":504,"line":619},5,[502,621,622],{"class":555},"    options",[502,624,260],{"class":559},[502,626,627],{"class":555},"Issuer ",[502,629,630],{"class":559},"=",[502,632,633],{"class":559}," new",[502,635,636],{"class":508}," Uri",[502,638,639],{"class":559},"(",[502,641,642],{"class":559},"\"",[502,644,645],{"class":512},"https:\u002F\u002Fapp.example.com\u002F",[502,647,642],{"class":559},[502,649,650],{"class":559},");\n",[502,652,654],{"class":504,"line":653},6,[502,655,572],{"emptyLinePlaceholder":571},[502,657,659],{"class":504,"line":658},7,[502,660,662],{"class":661},"sHwdD","    \u002F\u002F Two resources on this host. A token is for one of them and is accepted only there.\n",[502,664,666,668,670,673,675,678,681,683],{"class":504,"line":665},8,[502,667,622],{"class":555},[502,669,260],{"class":559},[502,671,672],{"class":555},"Audience ",[502,674,630],{"class":559},[502,676,677],{"class":559}," \"",[502,679,680],{"class":512},"https:\u002F\u002Fapp.example.com\u002Fapi",[502,682,642],{"class":559},[502,684,565],{"class":559},[502,686,688,690,692,694,696,699,701,703,705,707],{"class":504,"line":687},9,[502,689,622],{"class":555},[502,691,260],{"class":559},[502,693,409],{"class":555},[502,695,260],{"class":559},[502,697,698],{"class":588},"Add",[502,700,639],{"class":559},[502,702,642],{"class":559},[502,704,275],{"class":512},[502,706,642],{"class":559},[502,708,650],{"class":559},[502,710,712,714,716,718,720,722,724,726,728,730],{"class":504,"line":711},10,[502,713,622],{"class":555},[502,715,260],{"class":559},[502,717,412],{"class":555},[502,719,260],{"class":559},[502,721,698],{"class":588},[502,723,639],{"class":559},[502,725,642],{"class":559},[502,727,275],{"class":512},[502,729,642],{"class":559},[502,731,650],{"class":559},[502,733,735],{"class":504,"line":734},11,[502,736,572],{"emptyLinePlaceholder":571},[502,738,740],{"class":504,"line":739},12,[502,741,742],{"class":661},"    \u002F\u002F What a person can let an assistant do for them.\n",[502,744,746,748,750,753,755,757,759,761,764,766],{"class":504,"line":745},13,[502,747,622],{"class":555},[502,749,260],{"class":559},[502,751,752],{"class":555},"Scopes",[502,754,260],{"class":559},[502,756,698],{"class":588},[502,758,639],{"class":559},[502,760,642],{"class":559},[502,762,763],{"class":512},"mcp",[502,765,642],{"class":559},[502,767,650],{"class":559},[502,769,771,773,775,777,779,781,783,785,788,790],{"class":504,"line":770},14,[502,772,622],{"class":555},[502,774,260],{"class":559},[502,776,752],{"class":555},[502,778,260],{"class":559},[502,780,698],{"class":588},[502,782,639],{"class":559},[502,784,642],{"class":559},[502,786,787],{"class":512},"reports.read",[502,789,642],{"class":559},[502,791,650],{"class":559},[502,793,795,797,799,801,803,805,807,809,812,814,817],{"class":504,"line":794},15,[502,796,622],{"class":555},[502,798,260],{"class":559},[502,800,752],{"class":555},[502,802,260],{"class":559},[502,804,698],{"class":588},[502,806,639],{"class":559},[502,808,642],{"class":559},[502,810,811],{"class":512},"account",[502,813,642],{"class":559},[502,815,816],{"class":559},");",[502,818,819],{"class":661}," \u002F\u002F your own first-party clients only\n",[502,821,823],{"class":504,"line":822},16,[502,824,572],{"emptyLinePlaceholder":571},[502,826,828,830,832,835,837,839,842,844],{"class":504,"line":827},17,[502,829,622],{"class":555},[502,831,260],{"class":559},[502,833,834],{"class":555},"LoginUrl ",[502,836,630],{"class":559},[502,838,677],{"class":559},[502,840,841],{"class":512},"https:\u002F\u002Fapp.example.com\u002Fsign-in",[502,843,642],{"class":559},[502,845,565],{"class":559},[502,847,849,851,853,856,858,860,863,865],{"class":504,"line":848},18,[502,850,622],{"class":555},[502,852,260],{"class":559},[502,854,855],{"class":555},"ConsentUrl ",[502,857,630],{"class":559},[502,859,677],{"class":559},[502,861,862],{"class":512},"https:\u002F\u002Fapp.example.com\u002Foauth\u002Fconsent",[502,864,642],{"class":559},[502,866,565],{"class":559},[502,868,870,872,874,877,879,882,884,886,889,891],{"class":504,"line":869},19,[502,871,622],{"class":555},[502,873,260],{"class":559},[502,875,876],{"class":555},"Certificates",[502,878,260],{"class":559},[502,880,881],{"class":555},"Path ",[502,883,630],{"class":559},[502,885,677],{"class":559},[502,887,888],{"class":512},"\u002Fvar\u002Flib\u002Fmyapp\u002Foauth-keys",[502,890,642],{"class":559},[502,892,565],{"class":559},[502,894,896],{"class":504,"line":895},20,[502,897,572],{"emptyLinePlaceholder":571},[502,899,901],{"class":504,"line":900},21,[502,902,903],{"class":661},"    \u002F\u002F Assistants identify themselves with a metadata document, or register as a fallback.\n",[502,905,907,909,911,913,915,918,920,924],{"class":504,"line":906},22,[502,908,622],{"class":555},[502,910,260],{"class":559},[502,912,376],{"class":555},[502,914,260],{"class":559},[502,916,917],{"class":555},"Enabled ",[502,919,630],{"class":559},[502,921,923],{"class":922},"sfNiH"," true",[502,925,565],{"class":559},[502,927,929,931,933,935,937,939,941,943],{"class":504,"line":928},23,[502,930,622],{"class":555},[502,932,260],{"class":559},[502,934,379],{"class":555},[502,936,260],{"class":559},[502,938,917],{"class":555},[502,940,630],{"class":559},[502,942,923],{"class":922},[502,944,565],{"class":559},[502,946,948],{"class":504,"line":947},24,[502,949,950],{"class":661},"    \u002F\u002F Clients that anyone can bring may hold only these scopes (plus offline_access).\n",[502,952,954,956,958,960,962,965,967,969,971,973,975,977],{"class":504,"line":953},25,[502,955,622],{"class":555},[502,957,260],{"class":559},[502,959,379],{"class":555},[502,961,260],{"class":559},[502,963,964],{"class":555},"AllowedScopes",[502,966,260],{"class":559},[502,968,698],{"class":588},[502,970,639],{"class":559},[502,972,642],{"class":559},[502,974,763],{"class":512},[502,976,642],{"class":559},[502,978,650],{"class":559},[502,980,982,984,986,988,990,992,994,996,998,1000,1002,1004],{"class":504,"line":981},26,[502,983,622],{"class":555},[502,985,260],{"class":559},[502,987,379],{"class":555},[502,989,260],{"class":559},[502,991,964],{"class":555},[502,993,260],{"class":559},[502,995,698],{"class":588},[502,997,639],{"class":559},[502,999,642],{"class":559},[502,1001,787],{"class":512},[502,1003,642],{"class":559},[502,1005,650],{"class":559},[502,1007,1009],{"class":504,"line":1008},27,[502,1010,572],{"emptyLinePlaceholder":571},[502,1012,1014],{"class":504,"line":1013},28,[502,1015,1016],{"class":661},"    \u002F\u002F Discovery: one RFC 9728 document per resource, and a 401 that points at it.\n",[502,1018,1020,1022,1024,1026,1028,1030,1032,1034],{"class":504,"line":1019},29,[502,1021,622],{"class":555},[502,1023,260],{"class":559},[502,1025,362],{"class":555},[502,1027,260],{"class":559},[502,1029,917],{"class":555},[502,1031,630],{"class":559},[502,1033,923],{"class":922},[502,1035,565],{"class":559},[502,1037,1039,1041,1043,1045,1047,1050,1052,1054,1057,1059],{"class":504,"line":1038},30,[502,1040,622],{"class":555},[502,1042,260],{"class":559},[502,1044,362],{"class":555},[502,1046,260],{"class":559},[502,1048,1049],{"class":555},"ResourceName ",[502,1051,630],{"class":559},[502,1053,677],{"class":559},[502,1055,1056],{"class":512},"Example API",[502,1058,642],{"class":559},[502,1060,565],{"class":559},[502,1062,1064,1066,1068,1070,1072,1075,1077,1079,1081,1083,1085,1087],{"class":504,"line":1063},31,[502,1065,622],{"class":555},[502,1067,260],{"class":559},[502,1069,362],{"class":555},[502,1071,260],{"class":559},[502,1073,1074],{"class":555},"ChallengePaths",[502,1076,260],{"class":559},[502,1078,698],{"class":588},[502,1080,639],{"class":559},[502,1082,642],{"class":559},[502,1084,528],{"class":512},[502,1086,642],{"class":559},[502,1088,650],{"class":559},[502,1090,1092,1094,1096,1098,1100,1103,1105,1107,1110],{"class":504,"line":1091},32,[502,1093,622],{"class":555},[502,1095,260],{"class":559},[502,1097,362],{"class":555},[502,1099,260],{"class":559},[502,1101,1102],{"class":555},"Resources",[502,1104,260],{"class":559},[502,1106,698],{"class":588},[502,1108,1109],{"class":559},"(new",[502,1111,1112],{"class":508}," OAuthProtectedResourceDefinition\n",[502,1114,1116],{"class":504,"line":1115},33,[502,1117,1118],{"class":559},"    {\n",[502,1120,1122,1125,1127,1129,1131,1133],{"class":504,"line":1121},34,[502,1123,1124],{"class":555},"        Resource ",[502,1126,630],{"class":559},[502,1128,677],{"class":559},[502,1130,275],{"class":512},[502,1132,642],{"class":559},[502,1134,1135],{"class":559},",\n",[502,1137,1139,1142,1144,1146,1149,1151],{"class":504,"line":1138},35,[502,1140,1141],{"class":555},"        ResourceName ",[502,1143,630],{"class":559},[502,1145,677],{"class":559},[502,1147,1148],{"class":512},"Example MCP server",[502,1150,642],{"class":559},[502,1152,1135],{"class":559},[502,1154,1156,1159,1161,1164,1166,1168,1170,1172,1174,1176,1178],{"class":504,"line":1155},36,[502,1157,1158],{"class":555},"        Scopes ",[502,1160,630],{"class":559},[502,1162,1163],{"class":559}," {",[502,1165,677],{"class":559},[502,1167,763],{"class":512},[502,1169,642],{"class":559},[502,1171,598],{"class":559},[502,1173,677],{"class":559},[502,1175,787],{"class":512},[502,1177,642],{"class":559},[502,1179,1180],{"class":559}," },\n",[502,1182,1184,1187,1189,1191,1193,1195,1197],{"class":504,"line":1183},37,[502,1185,1186],{"class":555},"        ChallengePaths ",[502,1188,630],{"class":559},[502,1190,1163],{"class":559},[502,1192,677],{"class":559},[502,1194,282],{"class":512},[502,1196,642],{"class":559},[502,1198,1180],{"class":559},[502,1200,1202],{"class":504,"line":1201},38,[502,1203,1204],{"class":559},"    });\n",[502,1206,1208],{"class":504,"line":1207},39,[502,1209,572],{"emptyLinePlaceholder":571},[502,1211,1213],{"class":504,"line":1212},40,[502,1214,1215],{"class":661},"    \u002F\u002F Tokens carry the person's roles and user id, so existing checks work.\n",[502,1217,1219,1221,1223,1225,1227,1230,1232,1234],{"class":504,"line":1218},41,[502,1220,622],{"class":555},[502,1222,260],{"class":559},[502,1224,435],{"class":555},[502,1226,260],{"class":559},[502,1228,1229],{"class":555},"Roles ",[502,1231,630],{"class":559},[502,1233,923],{"class":922},[502,1235,565],{"class":559},[502,1237,1239,1241,1243,1245,1247,1250,1252,1254],{"class":504,"line":1238},42,[502,1240,622],{"class":555},[502,1242,260],{"class":559},[502,1244,435],{"class":555},[502,1246,260],{"class":559},[502,1248,1249],{"class":555},"UserId ",[502,1251,630],{"class":559},[502,1253,923],{"class":922},[502,1255,565],{"class":559},[502,1257,1259],{"class":504,"line":1258},43,[502,1260,1261],{"class":559},"})\n",[502,1263,1265,1267,1270,1272,1274,1277,1279,1281],{"class":504,"line":1264},44,[502,1266,260],{"class":559},[502,1268,1269],{"class":588},"BindConfiguration",[502,1271,639],{"class":559},[502,1273,642],{"class":559},[502,1275,1276],{"class":512},"OAuthServer",[502,1278,642],{"class":559},[502,1280,816],{"class":559},[502,1282,1283],{"class":661}," \u002F\u002F scope descriptions and host lists can live in appsettings\n",[244,1285,1286,1287,1289,1290,1292],{},"Keep any scope that acts as the person's whole account (here ",[251,1288,811],{},") out of ",[251,1291,382],{},". Clients that anyone can bring, by metadata document or by registration, then cannot ask for it. Configured clients and developer apps can still use it.",[1294,1295,1297],"h3",{"id":1296},"describe-the-scopes","Describe the scopes",[244,1299,1300,1301,1303],{},"The consent page should say \"Read your reports\", not ",[251,1302,787],{},", in the person's language:",[493,1305,1309],{"className":1306,"code":1307,"language":1308,"meta":498,"style":498},"language-json shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","{\n  \"OAuthServer\": {\n    \"ScopeDefinitions\": [\n      {\n        \"Name\": \"mcp\",\n        \"DisplayName\": \"Use the assistant tools\",\n        \"Description\": \"Run the tools of this app's MCP server as you, with your permissions.\",\n        \"DisplayNames\": { \"fr\": \"Utiliser les outils de l'assistant\" }\n      },\n      {\n        \"Name\": \"reports.read\",\n        \"DisplayName\": \"Read your reports\",\n        \"Description\": \"See the reports you can open. It cannot change them.\"\n      },\n      {\n        \"Name\": \"offline_access\",\n        \"DisplayName\": \"Stay connected\",\n        \"Description\": \"Keep access until you disconnect it.\"\n      }\n    ]\n  }\n}\n","json",[251,1310,1311,1315,1331,1345,1350,1370,1390,1410,1443,1448,1452,1470,1489,1507,1511,1515,1534,1553,1570,1575,1580,1585],{"__ignoreMap":498},[502,1312,1313],{"class":504,"line":505},[502,1314,616],{"class":559},[502,1316,1317,1320,1323,1325,1328],{"class":504,"line":568},[502,1318,1319],{"class":559},"  \"",[502,1321,1276],{"class":1322},"spNyl",[502,1324,642],{"class":559},[502,1326,1327],{"class":559},":",[502,1329,1330],{"class":559}," {\n",[502,1332,1333,1336,1338,1340,1342],{"class":504,"line":575},[502,1334,1335],{"class":559},"    \"",[502,1337,399],{"class":508},[502,1339,642],{"class":559},[502,1341,1327],{"class":559},[502,1343,1344],{"class":559}," [\n",[502,1346,1347],{"class":504,"line":613},[502,1348,1349],{"class":559},"      {\n",[502,1351,1352,1355,1358,1360,1362,1364,1366,1368],{"class":504,"line":619},[502,1353,1354],{"class":559},"        \"",[502,1356,1357],{"class":551},"Name",[502,1359,642],{"class":559},[502,1361,1327],{"class":559},[502,1363,677],{"class":559},[502,1365,763],{"class":512},[502,1367,642],{"class":559},[502,1369,1135],{"class":559},[502,1371,1372,1374,1377,1379,1381,1383,1386,1388],{"class":504,"line":653},[502,1373,1354],{"class":559},[502,1375,1376],{"class":551},"DisplayName",[502,1378,642],{"class":559},[502,1380,1327],{"class":559},[502,1382,677],{"class":559},[502,1384,1385],{"class":512},"Use the assistant tools",[502,1387,642],{"class":559},[502,1389,1135],{"class":559},[502,1391,1392,1394,1397,1399,1401,1403,1406,1408],{"class":504,"line":658},[502,1393,1354],{"class":559},[502,1395,1396],{"class":551},"Description",[502,1398,642],{"class":559},[502,1400,1327],{"class":559},[502,1402,677],{"class":559},[502,1404,1405],{"class":512},"Run the tools of this app's MCP server as you, with your permissions.",[502,1407,642],{"class":559},[502,1409,1135],{"class":559},[502,1411,1412,1414,1417,1419,1421,1423,1425,1429,1431,1433,1435,1438,1440],{"class":504,"line":665},[502,1413,1354],{"class":559},[502,1415,1416],{"class":551},"DisplayNames",[502,1418,642],{"class":559},[502,1420,1327],{"class":559},[502,1422,1163],{"class":559},[502,1424,677],{"class":559},[502,1426,1428],{"class":1427},"swJcz","fr",[502,1430,642],{"class":559},[502,1432,1327],{"class":559},[502,1434,677],{"class":559},[502,1436,1437],{"class":512},"Utiliser les outils de l'assistant",[502,1439,642],{"class":559},[502,1441,1442],{"class":559}," }\n",[502,1444,1445],{"class":504,"line":687},[502,1446,1447],{"class":559},"      },\n",[502,1449,1450],{"class":504,"line":711},[502,1451,1349],{"class":559},[502,1453,1454,1456,1458,1460,1462,1464,1466,1468],{"class":504,"line":734},[502,1455,1354],{"class":559},[502,1457,1357],{"class":551},[502,1459,642],{"class":559},[502,1461,1327],{"class":559},[502,1463,677],{"class":559},[502,1465,787],{"class":512},[502,1467,642],{"class":559},[502,1469,1135],{"class":559},[502,1471,1472,1474,1476,1478,1480,1482,1485,1487],{"class":504,"line":739},[502,1473,1354],{"class":559},[502,1475,1376],{"class":551},[502,1477,642],{"class":559},[502,1479,1327],{"class":559},[502,1481,677],{"class":559},[502,1483,1484],{"class":512},"Read your reports",[502,1486,642],{"class":559},[502,1488,1135],{"class":559},[502,1490,1491,1493,1495,1497,1499,1501,1504],{"class":504,"line":745},[502,1492,1354],{"class":559},[502,1494,1396],{"class":551},[502,1496,642],{"class":559},[502,1498,1327],{"class":559},[502,1500,677],{"class":559},[502,1502,1503],{"class":512},"See the reports you can open. It cannot change them.",[502,1505,1506],{"class":559},"\"\n",[502,1508,1509],{"class":504,"line":770},[502,1510,1447],{"class":559},[502,1512,1513],{"class":504,"line":794},[502,1514,1349],{"class":559},[502,1516,1517,1519,1521,1523,1525,1527,1530,1532],{"class":504,"line":822},[502,1518,1354],{"class":559},[502,1520,1357],{"class":551},[502,1522,642],{"class":559},[502,1524,1327],{"class":559},[502,1526,677],{"class":559},[502,1528,1529],{"class":512},"offline_access",[502,1531,642],{"class":559},[502,1533,1135],{"class":559},[502,1535,1536,1538,1540,1542,1544,1546,1549,1551],{"class":504,"line":827},[502,1537,1354],{"class":559},[502,1539,1376],{"class":551},[502,1541,642],{"class":559},[502,1543,1327],{"class":559},[502,1545,677],{"class":559},[502,1547,1548],{"class":512},"Stay connected",[502,1550,642],{"class":559},[502,1552,1135],{"class":559},[502,1554,1555,1557,1559,1561,1563,1565,1568],{"class":504,"line":848},[502,1556,1354],{"class":559},[502,1558,1396],{"class":551},[502,1560,642],{"class":559},[502,1562,1327],{"class":559},[502,1564,677],{"class":559},[502,1566,1567],{"class":512},"Keep access until you disconnect it.",[502,1569,1506],{"class":559},[502,1571,1572],{"class":504,"line":869},[502,1573,1574],{"class":559},"      }\n",[502,1576,1577],{"class":504,"line":895},[502,1578,1579],{"class":559},"    ]\n",[502,1581,1582],{"class":504,"line":900},[502,1583,1584],{"class":559},"  }\n",[502,1586,1587],{"class":504,"line":906},[502,1588,1589],{"class":559},"}\n",[244,1591,1592,1593,1596,1597,1600,1601,1604,1605,260],{},"The text is chosen for the request culture. Add ",[251,1594,1595],{},"app.UseRequestLocalization(…)"," if your consent page sends ",[251,1598,1599],{},"Accept-Language"," or a culture cookie. To load the text from a database or resource files instead, implement ",[251,1602,1603],{},"IOAuthScopeDescriptions"," and register it with ",[251,1606,1607],{},"AddScopeDescriptions\u003CT>()",[1294,1609,1611],{"id":1610},"limit-which-assistants-can-connect-optional","Limit which assistants can connect (optional)",[244,1613,1614],{},"Metadata document clients come from any public host by default. To accept only some hosts:",[493,1616,1618],{"className":542,"code":1617,"language":544,"meta":498,"style":498},"options.ClientMetadataDocuments.AllowedHosts.Add(\"assistant.example.com\");\noptions.ClientMetadataDocuments.AllowedHosts.Add(\"*.trusted.example\");\n",[251,1619,1620,1648],{"__ignoreMap":498},[502,1621,1622,1624,1626,1628,1630,1633,1635,1637,1639,1641,1644,1646],{"class":504,"line":505},[502,1623,607],{"class":555},[502,1625,260],{"class":559},[502,1627,376],{"class":555},[502,1629,260],{"class":559},[502,1631,1632],{"class":555},"AllowedHosts",[502,1634,260],{"class":559},[502,1636,698],{"class":588},[502,1638,639],{"class":559},[502,1640,642],{"class":559},[502,1642,1643],{"class":512},"assistant.example.com",[502,1645,642],{"class":559},[502,1647,650],{"class":559},[502,1649,1650,1652,1654,1656,1658,1660,1662,1664,1666,1668,1671,1673],{"class":504,"line":568},[502,1651,607],{"class":555},[502,1653,260],{"class":559},[502,1655,376],{"class":555},[502,1657,260],{"class":559},[502,1659,1632],{"class":555},[502,1661,260],{"class":559},[502,1663,698],{"class":588},[502,1665,639],{"class":559},[502,1667,642],{"class":559},[502,1669,1670],{"class":512},"*.trusted.example",[502,1672,642],{"class":559},[502,1674,650],{"class":559},[244,1676,1677,1678,287,1681,1684,1685,1688],{},"For a rule the lists cannot express, register an ",[251,1679,1680],{},"IOAuthClientMetadataHostFilter",[251,1682,1683],{},"AddClientMetadataHostFilter\u003CT>()",". To keep only metadata documents, leave ",[251,1686,1687],{},"DynamicRegistration.Enabled"," off. Many MCP clients still fall back to registration, so test the assistants you care about first.",[262,1690,1692],{"id":1691},"_2-add-the-tables","2. Add the tables",[493,1694,1696],{"className":542,"code":1695,"language":544,"meta":498,"style":498},"protected override void OnModelCreating(ModelBuilder builder)\n{\n    base.OnModelCreating(builder);\n    builder.UseAuthEndpointsOpenIddict\u003CAppUser>();\n}\n",[251,1697,1698,1723,1727,1743,1760],{"__ignoreMap":498},[502,1699,1700,1703,1706,1709,1712,1714,1717,1720],{"class":504,"line":505},[502,1701,1702],{"class":1322},"protected",[502,1704,1705],{"class":1322}," override",[502,1707,1708],{"class":559}," void",[502,1710,1711],{"class":588}," OnModelCreating",[502,1713,639],{"class":559},[502,1715,1716],{"class":508},"ModelBuilder",[502,1718,1719],{"class":508}," builder",[502,1721,1722],{"class":559},")\n",[502,1724,1725],{"class":504,"line":568},[502,1726,616],{"class":559},[502,1728,1729,1732,1734,1737,1739,1741],{"class":504,"line":575},[502,1730,1731],{"class":555},"    base",[502,1733,260],{"class":559},[502,1735,1736],{"class":588},"OnModelCreating",[502,1738,639],{"class":559},[502,1740,578],{"class":555},[502,1742,650],{"class":559},[502,1744,1745,1748,1750,1753,1755,1757],{"class":504,"line":613},[502,1746,1747],{"class":555},"    builder",[502,1749,260],{"class":559},[502,1751,1752],{"class":588},"UseAuthEndpointsOpenIddict",[502,1754,592],{"class":559},[502,1756,595],{"class":508},[502,1758,1759],{"class":559},">();\n",[502,1761,1762],{"class":504,"line":619},[502,1763,1589],{"class":559},[493,1765,1767],{"className":495,"code":1766,"language":497,"meta":498,"style":498},"dotnet ef migrations add OAuthServer\n",[251,1768,1769],{"__ignoreMap":498},[502,1770,1771,1773,1776,1779,1781],{"class":504,"line":505},[502,1772,509],{"class":508},[502,1774,1775],{"class":512}," ef",[502,1777,1778],{"class":512}," migrations",[502,1780,513],{"class":512},[502,1782,1783],{"class":512}," OAuthServer\n",[262,1785,1787],{"id":1786},"_3-map-the-routes","3. Map the routes",[493,1789,1791],{"className":542,"code":1790,"language":544,"meta":498,"style":498},"var app = builder.Build();\n\napp.UseOAuthResourceChallenge(); \u002F\u002F before authentication, so every 401 carries resource_metadata\napp.UseAuthEndpoints();          \u002F\u002F or UseAuthentication, UseAuthorization, UseAntiforgery\n\napp.MapOAuthServer();            \u002F\u002F authorize, register, metadata, and the consent API under \u002Foauth\n",[251,1792,1793,1814,1818,1834,1848,1852],{"__ignoreMap":498},[502,1794,1795,1798,1801,1804,1806,1808,1811],{"class":504,"line":505},[502,1796,1797],{"class":508},"var",[502,1799,1800],{"class":508}," app",[502,1802,1803],{"class":559}," =",[502,1805,1719],{"class":555},[502,1807,260],{"class":559},[502,1809,1810],{"class":588},"Build",[502,1812,1813],{"class":559},"();\n",[502,1815,1816],{"class":504,"line":568},[502,1817,572],{"emptyLinePlaceholder":571},[502,1819,1820,1823,1825,1828,1831],{"class":504,"line":575},[502,1821,1822],{"class":555},"app",[502,1824,260],{"class":559},[502,1826,1827],{"class":588},"UseOAuthResourceChallenge",[502,1829,1830],{"class":559},"();",[502,1832,1833],{"class":661}," \u002F\u002F before authentication, so every 401 carries resource_metadata\n",[502,1835,1836,1838,1840,1843,1845],{"class":504,"line":613},[502,1837,1822],{"class":555},[502,1839,260],{"class":559},[502,1841,1842],{"class":588},"UseAuthEndpoints",[502,1844,1830],{"class":559},[502,1846,1847],{"class":661},"          \u002F\u002F or UseAuthentication, UseAuthorization, UseAntiforgery\n",[502,1849,1850],{"class":504,"line":619},[502,1851,572],{"emptyLinePlaceholder":571},[502,1853,1854,1856,1858,1861,1863],{"class":504,"line":653},[502,1855,1822],{"class":555},[502,1857,260],{"class":559},[502,1859,1860],{"class":588},"MapOAuthServer",[502,1862,1830],{"class":559},[502,1864,1865],{"class":661},"            \u002F\u002F authorize, register, metadata, and the consent API under \u002Foauth\n",[244,1867,1868,1870,1871,363,1873,363,1876,363,1879,363,1881,363,1884,1887,1888,1891,1892,260],{},[251,1869,1860],{}," serves ",[251,1872,312],{},[251,1874,1875],{},"\u002Fconnect\u002Ftoken",[251,1877,1878],{},"\u002Fconnect\u002Frevoke",[251,1880,305],{},[251,1882,1883],{},"\u002F.well-known\u002Foauth-authorization-server",[251,1885,1886],{},"\u002F.well-known\u002Foauth-protected-resource"," and ",[251,1889,1890],{},"\u002F.well-known\u002Foauth-protected-resource\u002Fmcp",", and the consent API at ",[251,1893,1894],{},"\u002Foauth\u002Frequests\u002F{id}",[262,1896,1898],{"id":1897},"_4-protect-the-mcp-server","4. Protect the MCP server",[244,1900,1901,1902,1904,1905,1907],{},"Write one policy for the MCP endpoint. It accepts only tokens issued for ",[251,1903,282],{},", requires the ",[251,1906,763],{}," scope, and keeps the role check the same feature has for cookie users:",[493,1909,1911],{"className":542,"code":1910,"language":544,"meta":498,"style":498},"builder.Services.AddAuthorization(options =>\n{\n    options.AddPolicy(\"mcp\", policy => policy\n        .RequireOAuthAudience(\"https:\u002F\u002Fapp.example.com\u002Fmcp\") \u002F\u002F a token for \u002Fapi gets 403 here\n        .RequireOAuthScope(\"mcp\")                            \u002F\u002F and so does one without the scope\n        .RequireRole(\"Member\"));                             \u002F\u002F the person's own role, from AccessTokenClaims.Roles\n});\n\napp.MapMcp(\"\u002Fmcp\").RequireAuthorization(\"mcp\"); \u002F\u002F or your own MCP endpoint\n",[251,1912,1913,1932,1936,1964,1985,2004,2026,2031,2035],{"__ignoreMap":498},[502,1914,1915,1917,1919,1921,1923,1926,1928,1930],{"class":504,"line":505},[502,1916,578],{"class":555},[502,1918,260],{"class":559},[502,1920,583],{"class":555},[502,1922,260],{"class":559},[502,1924,1925],{"class":588},"AddAuthorization",[502,1927,639],{"class":559},[502,1929,607],{"class":508},[502,1931,610],{"class":559},[502,1933,1934],{"class":504,"line":568},[502,1935,616],{"class":559},[502,1937,1938,1940,1942,1945,1947,1949,1951,1953,1955,1958,1961],{"class":504,"line":575},[502,1939,622],{"class":555},[502,1941,260],{"class":559},[502,1943,1944],{"class":588},"AddPolicy",[502,1946,639],{"class":559},[502,1948,642],{"class":559},[502,1950,763],{"class":512},[502,1952,642],{"class":559},[502,1954,598],{"class":559},[502,1956,1957],{"class":508}," policy",[502,1959,1960],{"class":559}," =>",[502,1962,1963],{"class":555}," policy\n",[502,1965,1966,1969,1971,1973,1975,1977,1979,1982],{"class":504,"line":613},[502,1967,1968],{"class":559},"        .",[502,1970,423],{"class":588},[502,1972,639],{"class":559},[502,1974,642],{"class":559},[502,1976,275],{"class":512},[502,1978,642],{"class":559},[502,1980,1981],{"class":559},")",[502,1983,1984],{"class":661}," \u002F\u002F a token for \u002Fapi gets 403 here\n",[502,1986,1987,1989,1991,1993,1995,1997,1999,2001],{"class":504,"line":619},[502,1988,1968],{"class":559},[502,1990,426],{"class":588},[502,1992,639],{"class":559},[502,1994,642],{"class":559},[502,1996,763],{"class":512},[502,1998,642],{"class":559},[502,2000,1981],{"class":559},[502,2002,2003],{"class":661},"                            \u002F\u002F and so does one without the scope\n",[502,2005,2006,2008,2011,2013,2015,2018,2020,2023],{"class":504,"line":653},[502,2007,1968],{"class":559},[502,2009,2010],{"class":588},"RequireRole",[502,2012,639],{"class":559},[502,2014,642],{"class":559},[502,2016,2017],{"class":512},"Member",[502,2019,642],{"class":559},[502,2021,2022],{"class":559},"));",[502,2024,2025],{"class":661},"                             \u002F\u002F the person's own role, from AccessTokenClaims.Roles\n",[502,2027,2028],{"class":504,"line":658},[502,2029,2030],{"class":559},"});\n",[502,2032,2033],{"class":504,"line":665},[502,2034,572],{"emptyLinePlaceholder":571},[502,2036,2037,2039,2041,2044,2046,2048,2050,2052,2054,2057,2059,2061,2063,2065,2067],{"class":504,"line":687},[502,2038,1822],{"class":555},[502,2040,260],{"class":559},[502,2042,2043],{"class":588},"MapMcp",[502,2045,639],{"class":559},[502,2047,642],{"class":559},[502,2049,282],{"class":512},[502,2051,642],{"class":559},[502,2053,491],{"class":559},[502,2055,2056],{"class":588},"RequireAuthorization",[502,2058,639],{"class":559},[502,2060,642],{"class":559},[502,2062,763],{"class":512},[502,2064,642],{"class":559},[502,2066,816],{"class":559},[502,2068,2069],{"class":661}," \u002F\u002F or your own MCP endpoint\n",[244,2071,2072,2074],{},[251,2073,2043],{}," here is the endpoint of an MCP server library, such as the ModelContextProtocol.AspNetCore package. Any endpoint that serves MCP over HTTP works the same way: put the policy on it.",[244,2076,2077,2078,2080,2081,2084,2085,1327],{},"A tool that needs more than ",[251,2079,763],{}," checks the scope inside the handler, through the caller's principal. In a plain endpoint, ",[251,2082,2083],{},"Results.Forbid()"," answers a token caller with ",[251,2086,2087],{},"403",[493,2089,2091],{"className":542,"code":2090,"language":544,"meta":498,"style":498},"public sealed class ReportTools(IHttpContextAccessor http, ReportService reports)\n{\n    public async Task\u003CIReadOnlyList\u003CReport>> ListReports(CancellationToken ct)\n    {\n        var user = http.HttpContext!.User;\n        if (user.IsOAuthDelegated() && !user.HasOAuthScope(\"reports.read\"))\n        {\n            throw new UnauthorizedAccessException(\"The person did not allow this assistant to read reports.\");\n        }\n\n        \u002F\u002F The same service and the same role checks that cookie users go through.\n        return await reports.ListForAsync(user, ct);\n    }\n}\n",[251,2092,2093,2125,2129,2166,2170,2195,2238,2243,2264,2269,2273,2278,2303,2308],{"__ignoreMap":498},[502,2094,2095,2098,2101,2104,2107,2109,2112,2115,2117,2120,2123],{"class":504,"line":505},[502,2096,2097],{"class":1322},"public",[502,2099,2100],{"class":1322}," sealed",[502,2102,2103],{"class":508}," class",[502,2105,2106],{"class":508}," ReportTools",[502,2108,639],{"class":559},[502,2110,2111],{"class":508},"IHttpContextAccessor",[502,2113,2114],{"class":508}," http",[502,2116,598],{"class":559},[502,2118,2119],{"class":508}," ReportService",[502,2121,2122],{"class":508}," reports",[502,2124,1722],{"class":559},[502,2126,2127],{"class":504,"line":568},[502,2128,616],{"class":559},[502,2130,2131,2134,2137,2140,2142,2145,2147,2150,2153,2156,2158,2161,2164],{"class":504,"line":575},[502,2132,2133],{"class":1322},"    public",[502,2135,2136],{"class":1322}," async",[502,2138,2139],{"class":508}," Task",[502,2141,592],{"class":559},[502,2143,2144],{"class":508},"IReadOnlyList",[502,2146,592],{"class":559},[502,2148,2149],{"class":508},"Report",[502,2151,2152],{"class":559},">>",[502,2154,2155],{"class":588}," ListReports",[502,2157,639],{"class":559},[502,2159,2160],{"class":508},"CancellationToken",[502,2162,2163],{"class":508}," ct",[502,2165,1722],{"class":559},[502,2167,2168],{"class":504,"line":613},[502,2169,1118],{"class":559},[502,2171,2172,2175,2178,2180,2182,2184,2187,2190,2193],{"class":504,"line":619},[502,2173,2174],{"class":508},"        var",[502,2176,2177],{"class":508}," user",[502,2179,1803],{"class":559},[502,2181,2114],{"class":555},[502,2183,260],{"class":559},[502,2185,2186],{"class":555},"HttpContext",[502,2188,2189],{"class":559},"!.",[502,2191,2192],{"class":555},"User",[502,2194,565],{"class":559},[502,2196,2197,2201,2204,2207,2209,2212,2215,2218,2221,2223,2225,2227,2229,2231,2233,2235],{"class":504,"line":653},[502,2198,2200],{"class":2199},"s7zQu","        if",[502,2202,2203],{"class":559}," (",[502,2205,2206],{"class":555},"user",[502,2208,260],{"class":559},[502,2210,2211],{"class":588},"IsOAuthDelegated",[502,2213,2214],{"class":559},"()",[502,2216,2217],{"class":559}," &&",[502,2219,2220],{"class":559}," !",[502,2222,2206],{"class":555},[502,2224,260],{"class":559},[502,2226,432],{"class":588},[502,2228,639],{"class":559},[502,2230,642],{"class":559},[502,2232,787],{"class":512},[502,2234,642],{"class":559},[502,2236,2237],{"class":559},"))\n",[502,2239,2240],{"class":504,"line":658},[502,2241,2242],{"class":559},"        {\n",[502,2244,2245,2248,2250,2253,2255,2257,2260,2262],{"class":504,"line":665},[502,2246,2247],{"class":2199},"            throw",[502,2249,633],{"class":559},[502,2251,2252],{"class":508}," UnauthorizedAccessException",[502,2254,639],{"class":559},[502,2256,642],{"class":559},[502,2258,2259],{"class":512},"The person did not allow this assistant to read reports.",[502,2261,642],{"class":559},[502,2263,650],{"class":559},[502,2265,2266],{"class":504,"line":687},[502,2267,2268],{"class":559},"        }\n",[502,2270,2271],{"class":504,"line":711},[502,2272,572],{"emptyLinePlaceholder":571},[502,2274,2275],{"class":504,"line":734},[502,2276,2277],{"class":661},"        \u002F\u002F The same service and the same role checks that cookie users go through.\n",[502,2279,2280,2283,2286,2288,2290,2293,2295,2297,2299,2301],{"class":504,"line":739},[502,2281,2282],{"class":2199},"        return",[502,2284,2285],{"class":559}," await",[502,2287,2122],{"class":555},[502,2289,260],{"class":559},[502,2291,2292],{"class":588},"ListForAsync",[502,2294,639],{"class":559},[502,2296,2206],{"class":555},[502,2298,598],{"class":559},[502,2300,2163],{"class":555},[502,2302,650],{"class":559},[502,2304,2305],{"class":504,"line":745},[502,2306,2307],{"class":559},"    }\n",[502,2309,2310],{"class":504,"line":770},[502,2311,1589],{"class":559},[244,2313,2314,2315,2318,2319,1887,2322,2325,2326,2318,2329,1887,2332,2334],{},"With ",[251,2316,2317],{},"AccessTokenClaims.UserId"," on, ",[251,2320,2321],{},"UserManager.GetUserId(user)",[251,2323,2324],{},"ClaimTypes.NameIdentifier"," return the person's id, so services written for cookie users work unchanged. With ",[251,2327,2328],{},"AccessTokenClaims.Roles",[251,2330,2331],{},"IsInRole",[251,2333,2010],{}," see the person's Identity roles. They are read again at every refresh, so a role change reaches the assistant within one access token lifetime (15 minutes by default).",[244,2336,2337],{},"A scope never widens what the person may do. It narrows it. Keep the role or policy check every route already has, and add the scope check next to it.",[1294,2339,2341],{"id":2340},"routes-that-cookie-users-and-assistants-share","Routes that cookie users and assistants share",[244,2343,2344,2345,2347],{},"If an assistant should also call some of your ",[251,2346,528],{}," routes, accept both callers there and add the scope check only for tokens:",[493,2349,2351],{"className":542,"code":2350,"language":544,"meta":498,"style":498},"using OpenIddict.Abstractions; \u002F\u002F HasAudience\n\noptions.AddPolicy(\"reports.read\", policy => policy\n    .AddAuthenticationSchemes(IdentityConstants.ApplicationScheme, OAuthServerServiceCollectionExtensions.ValidationScheme)\n    .RequireRole(\"Member\")\n    .RequireOAuthScopeWhenDelegated(\"reports.read\")\n    \u002F\u002F A token must be for \u002Fapi. An \u002Fmcp token gets 403 here, even with the scope.\n    .RequireAssertion(context => !context.User.IsOAuthDelegated()\n        || context.User.HasAudience(\"https:\u002F\u002Fapp.example.com\u002Fapi\")));\n",[251,2352,2353,2371,2375,2399,2429,2445,2461,2466,2495],{"__ignoreMap":498},[502,2354,2355,2357,2360,2362,2365,2368],{"class":504,"line":505},[502,2356,552],{"class":551},[502,2358,2359],{"class":555}," OpenIddict",[502,2361,260],{"class":559},[502,2363,2364],{"class":555},"Abstractions",[502,2366,2367],{"class":559},";",[502,2369,2370],{"class":661}," \u002F\u002F HasAudience\n",[502,2372,2373],{"class":504,"line":568},[502,2374,572],{"emptyLinePlaceholder":571},[502,2376,2377,2379,2381,2383,2385,2387,2389,2391,2393,2395,2397],{"class":504,"line":575},[502,2378,607],{"class":555},[502,2380,260],{"class":559},[502,2382,1944],{"class":588},[502,2384,639],{"class":559},[502,2386,642],{"class":559},[502,2388,787],{"class":512},[502,2390,642],{"class":559},[502,2392,598],{"class":559},[502,2394,1957],{"class":508},[502,2396,1960],{"class":559},[502,2398,1963],{"class":555},[502,2400,2401,2404,2407,2409,2412,2414,2417,2419,2422,2424,2427],{"class":504,"line":613},[502,2402,2403],{"class":559},"    .",[502,2405,2406],{"class":588},"AddAuthenticationSchemes",[502,2408,639],{"class":559},[502,2410,2411],{"class":555},"IdentityConstants",[502,2413,260],{"class":559},[502,2415,2416],{"class":555},"ApplicationScheme",[502,2418,598],{"class":559},[502,2420,2421],{"class":555}," OAuthServerServiceCollectionExtensions",[502,2423,260],{"class":559},[502,2425,2426],{"class":555},"ValidationScheme",[502,2428,1722],{"class":559},[502,2430,2431,2433,2435,2437,2439,2441,2443],{"class":504,"line":619},[502,2432,2403],{"class":559},[502,2434,2010],{"class":588},[502,2436,639],{"class":559},[502,2438,642],{"class":559},[502,2440,2017],{"class":512},[502,2442,642],{"class":559},[502,2444,1722],{"class":559},[502,2446,2447,2449,2451,2453,2455,2457,2459],{"class":504,"line":653},[502,2448,2403],{"class":559},[502,2450,429],{"class":588},[502,2452,639],{"class":559},[502,2454,642],{"class":559},[502,2456,787],{"class":512},[502,2458,642],{"class":559},[502,2460,1722],{"class":559},[502,2462,2463],{"class":504,"line":658},[502,2464,2465],{"class":661},"    \u002F\u002F A token must be for \u002Fapi. An \u002Fmcp token gets 403 here, even with the scope.\n",[502,2467,2468,2470,2473,2475,2478,2480,2482,2484,2486,2488,2490,2492],{"class":504,"line":665},[502,2469,2403],{"class":559},[502,2471,2472],{"class":588},"RequireAssertion",[502,2474,639],{"class":559},[502,2476,2477],{"class":508},"context",[502,2479,1960],{"class":559},[502,2481,2220],{"class":559},[502,2483,2477],{"class":555},[502,2485,260],{"class":559},[502,2487,2192],{"class":555},[502,2489,260],{"class":559},[502,2491,2211],{"class":588},[502,2493,2494],{"class":559},"()\n",[502,2496,2497,2500,2503,2505,2507,2509,2512,2514,2516,2518,2520],{"class":504,"line":687},[502,2498,2499],{"class":559},"        ||",[502,2501,2502],{"class":555}," context",[502,2504,260],{"class":559},[502,2506,2192],{"class":555},[502,2508,260],{"class":559},[502,2510,2511],{"class":588},"HasAudience",[502,2513,639],{"class":559},[502,2515,642],{"class":559},[502,2517,680],{"class":512},[502,2519,642],{"class":559},[502,2521,2522],{"class":559},")));\n",[244,2524,2525,2526,2528,2529,2531,2532,2534,2535,2538,2539,2542,2543,2545,2546,2548,2549,2551,2552,2555],{},"A cookie caller passes the scope and audience checks. A token caller needs ",[251,2527,787],{}," and the ",[251,2530,528],{}," audience, and gets ",[251,2533,2087],{}," without either. It gets a status code, not the cookie's redirect to its access-denied page, because a request with ",[251,2536,2537],{},"Authorization: Bearer"," skips the cookie's redirects (",[251,2540,2541],{},"BearerRequestsSkipCookieRedirects",", on by default). Do not use ",[251,2544,423],{}," here: it accepts only token callers, so cookie users would get ",[251,2547,286],{},". To let an assistant call ",[251,2550,528],{},", it asks for ",[251,2553,2554],{},"resource=https:\u002F\u002Fapp.example.com\u002Fapi"," in its own authorization request.",[262,2557,2559],{"id":2558},"_5-build-the-consent-page","5. Build the consent page",[244,2561,2562,2564,2565,2568],{},[251,2563,312],{}," sends the signed-in person to ",[251,2566,2567],{},"ConsentUrl?request={id}",". Your page reads the card and shows it:",[493,2570,2574],{"className":2571,"code":2572,"language":2573,"meta":498,"style":498},"language-http shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","GET \u002Foauth\u002Frequests\u002F0193c5d4-…\n","http",[251,2575,2576],{"__ignoreMap":498},[502,2577,2578],{"class":504,"line":505},[502,2579,2572],{},[493,2581,2583],{"className":1306,"code":2582,"language":1308,"meta":498,"style":498},"{\n  \"id\": \"0193c5d4-…\",\n  \"clientId\": \"https:\u002F\u002Fassistant.example.com\u002Foauth\u002Fclient.json\",\n  \"clientName\": \"Example Assistant\",\n  \"clientHost\": \"assistant.example.com\",\n  \"redirectHost\": \"assistant.example.com\",\n  \"resource\": \"https:\u002F\u002Fapp.example.com\u002Fmcp\",\n  \"scopes\": [ \"mcp\", \"reports.read\", \"offline_access\" ],\n  \"scopeDetails\": [\n    { \"name\": \"mcp\", \"displayName\": \"Use the assistant tools\", \"description\": \"Run the tools of this app's MCP server as you, with your permissions.\" },\n    { \"name\": \"reports.read\", \"displayName\": \"Read your reports\", \"description\": \"See the reports you can open. It cannot change them.\" },\n    { \"name\": \"offline_access\", \"displayName\": \"Stay connected\", \"description\": \"Keep access until you disconnect it.\" }\n  ],\n  \"expiresAt\": \"…\"\n}\n",[251,2584,2585,2589,2609,2629,2649,2668,2687,2705,2744,2757,2813,2865,2917,2922,2940],{"__ignoreMap":498},[502,2586,2587],{"class":504,"line":505},[502,2588,616],{"class":559},[502,2590,2591,2593,2596,2598,2600,2602,2605,2607],{"class":504,"line":568},[502,2592,1319],{"class":559},[502,2594,2595],{"class":1322},"id",[502,2597,642],{"class":559},[502,2599,1327],{"class":559},[502,2601,677],{"class":559},[502,2603,2604],{"class":512},"0193c5d4-…",[502,2606,642],{"class":559},[502,2608,1135],{"class":559},[502,2610,2611,2613,2616,2618,2620,2622,2625,2627],{"class":504,"line":575},[502,2612,1319],{"class":559},[502,2614,2615],{"class":1322},"clientId",[502,2617,642],{"class":559},[502,2619,1327],{"class":559},[502,2621,677],{"class":559},[502,2623,2624],{"class":512},"https:\u002F\u002Fassistant.example.com\u002Foauth\u002Fclient.json",[502,2626,642],{"class":559},[502,2628,1135],{"class":559},[502,2630,2631,2633,2636,2638,2640,2642,2645,2647],{"class":504,"line":613},[502,2632,1319],{"class":559},[502,2634,2635],{"class":1322},"clientName",[502,2637,642],{"class":559},[502,2639,1327],{"class":559},[502,2641,677],{"class":559},[502,2643,2644],{"class":512},"Example Assistant",[502,2646,642],{"class":559},[502,2648,1135],{"class":559},[502,2650,2651,2653,2656,2658,2660,2662,2664,2666],{"class":504,"line":619},[502,2652,1319],{"class":559},[502,2654,2655],{"class":1322},"clientHost",[502,2657,642],{"class":559},[502,2659,1327],{"class":559},[502,2661,677],{"class":559},[502,2663,1643],{"class":512},[502,2665,642],{"class":559},[502,2667,1135],{"class":559},[502,2669,2670,2672,2675,2677,2679,2681,2683,2685],{"class":504,"line":653},[502,2671,1319],{"class":559},[502,2673,2674],{"class":1322},"redirectHost",[502,2676,642],{"class":559},[502,2678,1327],{"class":559},[502,2680,677],{"class":559},[502,2682,1643],{"class":512},[502,2684,642],{"class":559},[502,2686,1135],{"class":559},[502,2688,2689,2691,2693,2695,2697,2699,2701,2703],{"class":504,"line":658},[502,2690,1319],{"class":559},[502,2692,322],{"class":1322},[502,2694,642],{"class":559},[502,2696,1327],{"class":559},[502,2698,677],{"class":559},[502,2700,275],{"class":512},[502,2702,642],{"class":559},[502,2704,1135],{"class":559},[502,2706,2707,2709,2712,2714,2716,2719,2721,2723,2725,2727,2729,2731,2733,2735,2737,2739,2741],{"class":504,"line":665},[502,2708,1319],{"class":559},[502,2710,2711],{"class":1322},"scopes",[502,2713,642],{"class":559},[502,2715,1327],{"class":559},[502,2717,2718],{"class":559}," [",[502,2720,677],{"class":559},[502,2722,763],{"class":512},[502,2724,642],{"class":559},[502,2726,598],{"class":559},[502,2728,677],{"class":559},[502,2730,787],{"class":512},[502,2732,642],{"class":559},[502,2734,598],{"class":559},[502,2736,677],{"class":559},[502,2738,1529],{"class":512},[502,2740,642],{"class":559},[502,2742,2743],{"class":559}," ],\n",[502,2745,2746,2748,2751,2753,2755],{"class":504,"line":687},[502,2747,1319],{"class":559},[502,2749,2750],{"class":1322},"scopeDetails",[502,2752,642],{"class":559},[502,2754,1327],{"class":559},[502,2756,1344],{"class":559},[502,2758,2759,2762,2764,2767,2769,2771,2773,2775,2777,2779,2781,2784,2786,2788,2790,2792,2794,2796,2798,2801,2803,2805,2807,2809,2811],{"class":504,"line":711},[502,2760,2761],{"class":559},"    {",[502,2763,677],{"class":559},[502,2765,2766],{"class":508},"name",[502,2768,642],{"class":559},[502,2770,1327],{"class":559},[502,2772,677],{"class":559},[502,2774,763],{"class":512},[502,2776,642],{"class":559},[502,2778,598],{"class":559},[502,2780,677],{"class":559},[502,2782,2783],{"class":508},"displayName",[502,2785,642],{"class":559},[502,2787,1327],{"class":559},[502,2789,677],{"class":559},[502,2791,1385],{"class":512},[502,2793,642],{"class":559},[502,2795,598],{"class":559},[502,2797,677],{"class":559},[502,2799,2800],{"class":508},"description",[502,2802,642],{"class":559},[502,2804,1327],{"class":559},[502,2806,677],{"class":559},[502,2808,1405],{"class":512},[502,2810,642],{"class":559},[502,2812,1180],{"class":559},[502,2814,2815,2817,2819,2821,2823,2825,2827,2829,2831,2833,2835,2837,2839,2841,2843,2845,2847,2849,2851,2853,2855,2857,2859,2861,2863],{"class":504,"line":734},[502,2816,2761],{"class":559},[502,2818,677],{"class":559},[502,2820,2766],{"class":508},[502,2822,642],{"class":559},[502,2824,1327],{"class":559},[502,2826,677],{"class":559},[502,2828,787],{"class":512},[502,2830,642],{"class":559},[502,2832,598],{"class":559},[502,2834,677],{"class":559},[502,2836,2783],{"class":508},[502,2838,642],{"class":559},[502,2840,1327],{"class":559},[502,2842,677],{"class":559},[502,2844,1484],{"class":512},[502,2846,642],{"class":559},[502,2848,598],{"class":559},[502,2850,677],{"class":559},[502,2852,2800],{"class":508},[502,2854,642],{"class":559},[502,2856,1327],{"class":559},[502,2858,677],{"class":559},[502,2860,1503],{"class":512},[502,2862,642],{"class":559},[502,2864,1180],{"class":559},[502,2866,2867,2869,2871,2873,2875,2877,2879,2881,2883,2885,2887,2889,2891,2893,2895,2897,2899,2901,2903,2905,2907,2909,2911,2913,2915],{"class":504,"line":739},[502,2868,2761],{"class":559},[502,2870,677],{"class":559},[502,2872,2766],{"class":508},[502,2874,642],{"class":559},[502,2876,1327],{"class":559},[502,2878,677],{"class":559},[502,2880,1529],{"class":512},[502,2882,642],{"class":559},[502,2884,598],{"class":559},[502,2886,677],{"class":559},[502,2888,2783],{"class":508},[502,2890,642],{"class":559},[502,2892,1327],{"class":559},[502,2894,677],{"class":559},[502,2896,1548],{"class":512},[502,2898,642],{"class":559},[502,2900,598],{"class":559},[502,2902,677],{"class":559},[502,2904,2800],{"class":508},[502,2906,642],{"class":559},[502,2908,1327],{"class":559},[502,2910,677],{"class":559},[502,2912,1567],{"class":512},[502,2914,642],{"class":559},[502,2916,1442],{"class":559},[502,2918,2919],{"class":504,"line":745},[502,2920,2921],{"class":559},"  ],\n",[502,2923,2924,2926,2929,2931,2933,2935,2938],{"class":504,"line":770},[502,2925,1319],{"class":559},[502,2927,2928],{"class":1322},"expiresAt",[502,2930,642],{"class":559},[502,2932,1327],{"class":559},[502,2934,677],{"class":559},[502,2936,2937],{"class":512},"…",[502,2939,1506],{"class":559},[502,2941,2942],{"class":504,"line":794},[502,2943,1589],{"class":559},[463,2945,2946,2968,2974],{},[270,2947,2948,2949,2951,2952,2954,2955,2957,2958,2960,2961,2964,2965,2967],{},"Show ",[251,2950,2635],{}," together with ",[251,2953,2655],{},". The name is whatever the client claims, and ",[251,2956,2655],{}," is the domain that published it. For a dynamically registered client, ",[251,2959,2655],{}," is ",[251,2962,2963],{},"null",", so show ",[251,2966,2674],{},", where the code will be sent.",[270,2969,2970,2971,2973],{},"List ",[251,2972,2750],{}," as the things the person allows.",[270,2975,2976,2977,2980,2981,2984,2985,2988],{},"Approve with ",[251,2978,2979],{},"POST \u002Foauth\u002Frequests\u002F{id}\u002Fapprove"," and deny with ",[251,2982,2983],{},"POST \u002Foauth\u002Frequests\u002F{id}\u002Fdeny",", both with your CSRF header. Each returns ",[251,2986,2987],{},"{ redirectUrl }",". Send the browser there.",[244,2990,2991,2992,260],{},"The full contract, including approving from your own endpoint, is in ",[256,2993,2995],{"href":2994},"https:\u002F\u002Fgithub.com\u002Fmadeyoga\u002FAuthEndpoints\u002Ftree\u002Fmain\u002Fsrc\u002FAuthEndpoints.OpenIddict#the-consent-step","The consent step",[262,2997,2999],{"id":2998},"_6-what-the-assistant-does","6. What the assistant does",[244,3001,3002],{},"You do not write this part. It helps to know what the assistant sends when you read your logs.",[493,3004,3006],{"className":2571,"code":3005,"language":2573,"meta":498,"style":498},"GET \u002Fmcp\n→ 401  WWW-Authenticate: Bearer resource_metadata=\"https:\u002F\u002Fapp.example.com\u002F.well-known\u002Foauth-protected-resource\u002Fmcp\"\n\nGET \u002F.well-known\u002Foauth-protected-resource\u002Fmcp\n→ { \"resource\": \"https:\u002F\u002Fapp.example.com\u002Fmcp\", \"authorization_servers\": [\"https:\u002F\u002Fapp.example.com\u002F\"],\n    \"scopes_supported\": [\"mcp\", \"reports.read\"], \"resource_name\": \"Example MCP server\", … }\n\nGET \u002F.well-known\u002Foauth-authorization-server\n→ { …, \"client_id_metadata_document_supported\": true, \"registration_endpoint\": \"https:\u002F\u002Fapp.example.com\u002Fconnect\u002Fregister\",\n    \"code_challenge_methods_supported\": [\"S256\"], … }\n\nGET \u002Fconnect\u002Fauthorize?client_id=https%3A%2F%2Fassistant.example.com%2Foauth%2Fclient.json\n    &redirect_uri=…&response_type=code&code_challenge=…&code_challenge_method=S256\n    &scope=mcp%20reports.read%20offline_access&resource=https%3A%2F%2Fapp.example.com%2Fmcp&state=…\n→ (sign-in if needed) → 302 to ConsentUrl?request=…  → after approval, 302 to the assistant with code, state, iss\n\nPOST \u002Fconnect\u002Ftoken  grant_type=authorization_code&code=…&code_verifier=…&client_id=…&redirect_uri=…&resource=…\n→ { \"access_token\": \"…\", \"refresh_token\": \"…\", \"expires_in\": 900, … }\n",[251,3007,3008,3013,3018,3022,3027,3032,3037,3041,3046,3051,3056,3060,3065,3070,3075,3080,3084,3089],{"__ignoreMap":498},[502,3009,3010],{"class":504,"line":505},[502,3011,3012],{},"GET \u002Fmcp\n",[502,3014,3015],{"class":504,"line":568},[502,3016,3017],{},"→ 401  WWW-Authenticate: Bearer resource_metadata=\"https:\u002F\u002Fapp.example.com\u002F.well-known\u002Foauth-protected-resource\u002Fmcp\"\n",[502,3019,3020],{"class":504,"line":575},[502,3021,572],{"emptyLinePlaceholder":571},[502,3023,3024],{"class":504,"line":613},[502,3025,3026],{},"GET \u002F.well-known\u002Foauth-protected-resource\u002Fmcp\n",[502,3028,3029],{"class":504,"line":619},[502,3030,3031],{},"→ { \"resource\": \"https:\u002F\u002Fapp.example.com\u002Fmcp\", \"authorization_servers\": [\"https:\u002F\u002Fapp.example.com\u002F\"],\n",[502,3033,3034],{"class":504,"line":653},[502,3035,3036],{},"    \"scopes_supported\": [\"mcp\", \"reports.read\"], \"resource_name\": \"Example MCP server\", … }\n",[502,3038,3039],{"class":504,"line":658},[502,3040,572],{"emptyLinePlaceholder":571},[502,3042,3043],{"class":504,"line":665},[502,3044,3045],{},"GET \u002F.well-known\u002Foauth-authorization-server\n",[502,3047,3048],{"class":504,"line":687},[502,3049,3050],{},"→ { …, \"client_id_metadata_document_supported\": true, \"registration_endpoint\": \"https:\u002F\u002Fapp.example.com\u002Fconnect\u002Fregister\",\n",[502,3052,3053],{"class":504,"line":711},[502,3054,3055],{},"    \"code_challenge_methods_supported\": [\"S256\"], … }\n",[502,3057,3058],{"class":504,"line":734},[502,3059,572],{"emptyLinePlaceholder":571},[502,3061,3062],{"class":504,"line":739},[502,3063,3064],{},"GET \u002Fconnect\u002Fauthorize?client_id=https%3A%2F%2Fassistant.example.com%2Foauth%2Fclient.json\n",[502,3066,3067],{"class":504,"line":745},[502,3068,3069],{},"    &redirect_uri=…&response_type=code&code_challenge=…&code_challenge_method=S256\n",[502,3071,3072],{"class":504,"line":770},[502,3073,3074],{},"    &scope=mcp%20reports.read%20offline_access&resource=https%3A%2F%2Fapp.example.com%2Fmcp&state=…\n",[502,3076,3077],{"class":504,"line":794},[502,3078,3079],{},"→ (sign-in if needed) → 302 to ConsentUrl?request=…  → after approval, 302 to the assistant with code, state, iss\n",[502,3081,3082],{"class":504,"line":822},[502,3083,572],{"emptyLinePlaceholder":571},[502,3085,3086],{"class":504,"line":827},[502,3087,3088],{},"POST \u002Fconnect\u002Ftoken  grant_type=authorization_code&code=…&code_verifier=…&client_id=…&redirect_uri=…&resource=…\n",[502,3090,3091],{"class":504,"line":848},[502,3092,3093],{},"→ { \"access_token\": \"…\", \"refresh_token\": \"…\", \"expires_in\": 900, … }\n",[244,3095,3096,3097,3099,3100,3103,3104,3106],{},"When the ",[251,3098,301],{}," is a URL, your server fetches that document once and caches it within bounds. It refuses private and loopback addresses, redirects, and documents over 5 KB. The client must be public, its ",[251,3101,3102],{},"redirect_uris"," must follow the same rules as dynamic registration, and its scopes are limited to ",[251,3105,382],{},". The client is stored in OpenIddict's application store, so refresh, revocation, and cleanup work as for any other client.",[262,3108,3110],{"id":3109},"_7-disconnect-an-assistant","7. Disconnect an assistant",[244,3112,3113,3115,3116,3119,3120,3123,3124,3127,3128,3130],{},[251,3114,1860],{}," maps the connected apps routes for the signed-in person: ",[251,3117,3118],{},"GET \u002Foauth\u002Fauthorizations"," lists the assistants they connected (name, kind, host when known, scopes, resource, created, and last used with ",[251,3121,3122],{},"RecordLastUsed","), and ",[251,3125,3126],{},"DELETE \u002Foauth\u002Fauthorizations\u002F{id}"," disconnects one. The routes take the sign-in cookie only, so an assistant's token cannot call them. For an admin page, call ",[251,3129,454],{}," with the user id.",[244,3132,3133],{},"To end one assistant's access from your own code, revoke its authorization. That also revokes every token issued from it:",[493,3135,3137],{"className":542,"code":3136,"language":544,"meta":498,"style":498},"app.MapDelete(\"\u002Fapi\u002Fconnections\u002F{authorizationId}\", async (string authorizationId, IOAuthConsentService consent) =>\n    await consent.RevokeAuthorizationAsync(authorizationId) ? Results.NoContent() : Results.NotFound())\n    .RequireAuthorization(\"admin\")\n    .RequireAntiforgery(allowBearer: false);\n",[251,3138,3139,3181,3226,3243],{"__ignoreMap":498},[502,3140,3141,3143,3145,3148,3150,3152,3155,3157,3159,3161,3163,3166,3169,3171,3174,3177,3179],{"class":504,"line":505},[502,3142,1822],{"class":555},[502,3144,260],{"class":559},[502,3146,3147],{"class":588},"MapDelete",[502,3149,639],{"class":559},[502,3151,642],{"class":559},[502,3153,3154],{"class":512},"\u002Fapi\u002Fconnections\u002F{authorizationId}",[502,3156,642],{"class":559},[502,3158,598],{"class":559},[502,3160,2136],{"class":1322},[502,3162,2203],{"class":559},[502,3164,3165],{"class":559},"string",[502,3167,3168],{"class":508}," authorizationId",[502,3170,598],{"class":559},[502,3172,3173],{"class":508}," IOAuthConsentService",[502,3175,3176],{"class":508}," consent",[502,3178,1981],{"class":559},[502,3180,610],{"class":559},[502,3182,3183,3186,3188,3190,3193,3195,3198,3200,3203,3206,3208,3211,3213,3216,3218,3220,3223],{"class":504,"line":568},[502,3184,3185],{"class":559},"    await",[502,3187,3176],{"class":555},[502,3189,260],{"class":559},[502,3191,3192],{"class":588},"RevokeAuthorizationAsync",[502,3194,639],{"class":559},[502,3196,3197],{"class":555},"authorizationId",[502,3199,1981],{"class":559},[502,3201,3202],{"class":559}," ?",[502,3204,3205],{"class":555}," Results",[502,3207,260],{"class":559},[502,3209,3210],{"class":588},"NoContent",[502,3212,2214],{"class":559},[502,3214,3215],{"class":559}," :",[502,3217,3205],{"class":555},[502,3219,260],{"class":559},[502,3221,3222],{"class":588},"NotFound",[502,3224,3225],{"class":559},"())\n",[502,3227,3228,3230,3232,3234,3236,3239,3241],{"class":504,"line":575},[502,3229,2403],{"class":559},[502,3231,2056],{"class":588},[502,3233,639],{"class":559},[502,3235,642],{"class":559},[502,3237,3238],{"class":512},"admin",[502,3240,642],{"class":559},[502,3242,1722],{"class":559},[502,3244,3245,3247,3250,3252,3255,3257,3260],{"class":504,"line":613},[502,3246,2403],{"class":559},[502,3248,3249],{"class":588},"RequireAntiforgery",[502,3251,639],{"class":559},[502,3253,3254],{"class":508},"allowBearer",[502,3256,1327],{"class":559},[502,3258,3259],{"class":922}," false",[502,3261,650],{"class":559},[244,3263,3264,3267],{},[251,3265,3266],{},"ApproveAsync"," returns the authorization id when your own approve endpoint calls it, so you can store it next to the person. Before you revoke an authorization on a person's behalf, check that it belongs to them.",[244,3269,3270,3271,3274],{},"To end every grant for a person, change their security stamp with ",[251,3272,3273],{},"UserManager.UpdateSecurityStampAsync(user)",". The next refresh of each grant fails and the grant is revoked. An access token that was already issued works until it expires.",[262,3276,3278],{"id":3277},"checklist","Checklist",[463,3280,3281,3296,3299,3304,3318,3329,3334,3341],{},[270,3282,3283,3284,3286,3287,3289,3290,3292,3293,3295],{},"Assistant tokens work only on ",[251,3285,282],{},", through ",[251,3288,423],{},". A token for ",[251,3291,528],{}," gets ",[251,3294,2087],{}," there.",[270,3297,3298],{},"Every MCP route has a scope check and the same role or policy check that cookie users go through.",[270,3300,3301,3303],{},[251,3302,382],{}," lists only the scopes that clients anyone can bring may ask for.",[270,3305,3306,3307,3309,3310,3312,3313,3315,3316,260],{},"The consent page shows ",[251,3308,2655],{}," (or ",[251,3311,2674],{},") next to ",[251,3314,2635],{},", and uses ",[251,3317,2750],{},[270,3319,3320,3321,1887,3323,3325,3326,3328],{},"Token callers get ",[251,3322,286],{},[251,3324,2087],{},", never the sign-in cookie's redirects (keep ",[251,3327,2541],{}," on).",[270,3330,3331,3332,260],{},"Behind a reverse proxy, forwarded headers are configured, so rate limits see the real client IP and the server sees ",[251,3333,297],{},[270,3335,3336,3337,3340],{},"Routes that change a password, two-factor, passkeys, or approve consent keep ",[251,3338,3339],{},"RequireAntiforgery(allowBearer: false)",", so a token cannot call them.",[270,3342,3343,3344,3347,3348,3350,3351,260],{},"Your own person-only routes (account deletion, API keys, billing) add ",[251,3345,3346],{},"RequireDirectPerson()",", so an assistant's token gets ",[251,3349,2087],{}," there before you give it write tools. See ",[256,3352,207],{"href":3353},"\u002Fmodules\u002Fcallers\u002F",[262,3355,3357],{"id":3356},"not-covered-yet","Not covered yet",[244,3359,3360,3361,1327],{},"These are tracked in the ",[256,3362,3364],{"href":3363},"https:\u002F\u002Fgithub.com\u002Fmadeyoga\u002FAuthEndpoints\u002Fissues\u002F438","roadmap issue #438",[463,3366,3367],{},[270,3368,3369,3372],{},[251,3370,3371],{},"private_key_jwt"," client authentication for metadata document clients.",[3374,3375,3376],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}",{"title":498,"searchDepth":505,"depth":568,"links":3378},[3379,3380,3381,3385,3386,3387,3390,3391,3392,3393,3394],{"id":264,"depth":568,"text":265},{"id":460,"depth":568,"text":461},{"id":538,"depth":568,"text":539,"children":3382},[3383,3384],{"id":1296,"depth":575,"text":1297},{"id":1610,"depth":575,"text":1611},{"id":1691,"depth":568,"text":1692},{"id":1786,"depth":568,"text":1787},{"id":1897,"depth":568,"text":1898,"children":3388},[3389],{"id":2340,"depth":575,"text":2341},{"id":2558,"depth":568,"text":2559},{"id":2998,"depth":568,"text":2999},{"id":3109,"depth":568,"text":3110},{"id":3277,"depth":568,"text":3278},{"id":3356,"depth":568,"text":3357},"Let AI assistants and other MCP clients connect to your app as the signed-in person, with that person's roles and only the scopes they approved.","md",null,{},{"title":110,"icon":113},{"title":239,"description":3395},"aukNOT8G09eNNl46gMTN5bURJCWTyyCFdzQfQvJ5T_E",[3403,3405],{"title":105,"path":106,"stem":107,"description":3404,"icon":108,"children":-1},"Let users see where they are signed in and sign out other browsers or devices, for cookie and JWT sessions.",{"title":115,"path":116,"stem":117,"description":3406,"icon":103,"children":-1},"Keep an OAuth client in the organization, workspace, or region the person chose at consent, and check it again at every refresh.",1795238828299]