|
| 1 | +--- |
| 2 | +# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. |
| 3 | +# SPDX-License-Identifier: Apache-2.0 |
| 4 | +title: "Broker Microsoft Agent S2S Tokens with Providers v2" |
| 5 | +sidebar-title: "Microsoft Agent S2S Provider" |
| 6 | +slug: "get-started/tutorials/microsoft-agent-s2s" |
| 7 | +description: "Create a microsoft-agent-s2s provider, attach it to a sandbox, and verify that the workload receives a brokered runtime token URL instead of the Microsoft secret." |
| 8 | +keywords: "Generative AI, Cybersecurity, Tutorial, Providers, Microsoft, A365, Agent 365, S2S, Token Broker" |
| 9 | +--- |
| 10 | + |
| 11 | +Use Providers v2 to keep Microsoft Agent service-to-service identity material at the gateway while sandboxed workloads request short-lived tokens on demand. Instead of injecting a static bearer token or the blueprint client secret into the sandbox, OpenShell injects a sandbox-local token provider URL and brokers Microsoft tokens for approved audiences at runtime. |
| 12 | + |
| 13 | +After completing this tutorial, you have: |
| 14 | + |
| 15 | +- A `microsoft-agent-s2s` provider instance on your gateway. |
| 16 | +- A sandbox with the provider attached. |
| 17 | +- A concrete example of the runtime contract the workload receives: `A365_TOKEN_PROVIDER_URL`. |
| 18 | + |
| 19 | +<Warning> |
| 20 | +Do not commit Microsoft client secrets, local `.env` files, or emitted bearer tokens. The commands below pass secret material to the gateway; they are not examples of values to store in source control. |
| 21 | +</Warning> |
| 22 | + |
| 23 | +<Steps toc={true}> |
| 24 | + |
| 25 | +## Prerequisites |
| 26 | + |
| 27 | +- A working OpenShell installation with an active gateway. Complete the [Quickstart](/get-started/quickstart) before proceeding. |
| 28 | +- Providers v2 enabled on the active gateway. |
| 29 | +- A Microsoft setup that already provides: |
| 30 | + - `AZURE_TENANT_ID` |
| 31 | + - `A365_BLUEPRINT_CLIENT_ID` |
| 32 | + - `A365_BLUEPRINT_CLIENT_SECRET` |
| 33 | + - `A365_RUNTIME_AGENT_ID` |
| 34 | + - `A365_ALLOWED_AUDIENCES` |
| 35 | + |
| 36 | +`A365_ALLOWED_AUDIENCES` is a comma-separated list of downstream audiences that the sandboxed workload may request tokens for. |
| 37 | + |
| 38 | +## Enable Providers v2 |
| 39 | + |
| 40 | +Enable provider profile policy composition on the active gateway: |
| 41 | + |
| 42 | +```shell |
| 43 | +openshell settings set --global --key providers_v2_enabled --value true --yes |
| 44 | +``` |
| 45 | + |
| 46 | +## Inspect the Built-in Profile |
| 47 | + |
| 48 | +Export the built-in `microsoft-agent-s2s` profile: |
| 49 | + |
| 50 | +```shell |
| 51 | +openshell provider profile export microsoft-agent-s2s -o yaml |
| 52 | +``` |
| 53 | + |
| 54 | +The built-in profile intentionally does not include default network policy. It defines the provider type and discovery shape only. |
| 55 | + |
| 56 | +## Create the Provider |
| 57 | + |
| 58 | +Create a provider instance from the Microsoft S2S inputs: |
| 59 | + |
| 60 | +```shell |
| 61 | +openshell provider create \ |
| 62 | + --name microsoft-a365 \ |
| 63 | + --type microsoft-agent-s2s \ |
| 64 | + --credential A365_BLUEPRINT_CLIENT_SECRET="$A365_BLUEPRINT_CLIENT_SECRET" \ |
| 65 | + --config AZURE_TENANT_ID="$AZURE_TENANT_ID" \ |
| 66 | + --config A365_BLUEPRINT_CLIENT_ID="$A365_BLUEPRINT_CLIENT_ID" \ |
| 67 | + --config A365_RUNTIME_AGENT_ID="$A365_RUNTIME_AGENT_ID" \ |
| 68 | + --config A365_ALLOWED_AUDIENCES="$A365_ALLOWED_AUDIENCES" |
| 69 | +``` |
| 70 | + |
| 71 | +The provider stores: |
| 72 | + |
| 73 | +- `A365_BLUEPRINT_CLIENT_SECRET` as the secret credential |
| 74 | +- `AZURE_TENANT_ID`, `A365_BLUEPRINT_CLIENT_ID`, `A365_RUNTIME_AGENT_ID`, and `A365_ALLOWED_AUDIENCES` as provider config |
| 75 | + |
| 76 | +Unlike a normal placeholder provider, the sandbox does not receive `A365_BLUEPRINT_CLIENT_SECRET` directly. |
| 77 | + |
| 78 | +## Launch a Sandbox |
| 79 | + |
| 80 | +Launch a simple sandbox with the provider attached: |
| 81 | + |
| 82 | +```shell |
| 83 | +openshell sandbox create \ |
| 84 | + --name microsoft-a365-demo \ |
| 85 | + --keep \ |
| 86 | + --provider microsoft-a365 \ |
| 87 | + --no-auto-providers \ |
| 88 | + -- /bin/sh |
| 89 | +``` |
| 90 | + |
| 91 | +This tutorial uses `/bin/sh` so you can inspect the runtime contract directly. Substitute your own A365 workload image or startup command later. |
| 92 | + |
| 93 | +## Verify the Runtime Contract |
| 94 | + |
| 95 | +Inside the sandbox, inspect the injected token broker metadata: |
| 96 | + |
| 97 | +```shell |
| 98 | +env | grep '^A365_TOKEN_PROVIDER_URL\|^OPENSHELL_MICROSOFT_AGENT_S2S' |
| 99 | +``` |
| 100 | + |
| 101 | +You should see a local token provider URL and related metadata, for example: |
| 102 | + |
| 103 | +```text |
| 104 | +A365_TOKEN_PROVIDER_URL=http://<sandbox-local-resolver>/v1/microsoft-agent-s2s/token/<provider-id> |
| 105 | +OPENSHELL_MICROSOFT_AGENT_S2S_TOKEN_PROVIDER_URL=http://<sandbox-local-resolver>/v1/microsoft-agent-s2s/token/<provider-id> |
| 106 | +OPENSHELL_MICROSOFT_AGENT_S2S_TOKEN_URL=http://<sandbox-local-resolver>/v1/microsoft-agent-s2s/token/<provider-id> |
| 107 | +OPENSHELL_MICROSOFT_AGENT_S2S_DEFAULT_AUDIENCE=<audience> |
| 108 | +``` |
| 109 | + |
| 110 | +The important difference from placeholder providers is that the sandbox receives a token URL rather than the blueprint client secret. |
| 111 | + |
| 112 | +## Request a Token from the Local Broker |
| 113 | + |
| 114 | +If your workload knows the audience it wants, it can call the broker URL directly. For example, from inside the sandbox: |
| 115 | + |
| 116 | +```shell |
| 117 | +curl -sS "${A365_TOKEN_PROVIDER_URL}?audience=${OPENSHELL_MICROSOFT_AGENT_S2S_DEFAULT_AUDIENCE}" |
| 118 | +``` |
| 119 | + |
| 120 | +The exact response shape depends on the workload-side adapter, but the flow is always the same: |
| 121 | + |
| 122 | +1. the workload calls the sandbox-local token URL |
| 123 | +2. the gateway checks that the sandbox has the provider attached |
| 124 | +3. the gateway verifies that the requested audience is allowed |
| 125 | +4. the gateway returns a short-lived Microsoft bearer token |
| 126 | + |
| 127 | +OpenShell keeps the blueprint secret and the Microsoft token exchange at the gateway boundary. |
| 128 | + |
| 129 | +## Use the Contract from a Workload |
| 130 | + |
| 131 | +Workloads that already support a token callback can consume the broker directly. For example, the NAT/A365 integration we validated uses this shape: |
| 132 | + |
| 133 | +```yaml |
| 134 | +authentication: |
| 135 | + a365_auth: |
| 136 | + _type: openshell_bearer_token |
| 137 | + token_url: ${A365_TOKEN_PROVIDER_URL} |
| 138 | + audience: "<audience>" |
| 139 | +``` |
| 140 | +
|
| 141 | +A non-NAT Microsoft agent can use the same OpenShell provider as long as it can request tokens from a callback or token-provider URL instead of requiring a static bearer token or direct access to the Microsoft secret material. |
| 142 | +
|
| 143 | +</Steps> |
0 commit comments