|
| 1 | +--- |
| 2 | +title: "BFF Configuration" |
| 3 | +description: Documentation for managing BFF configuration |
| 4 | +sidebar: |
| 5 | + order: 3 |
| 6 | + label: "Configuration" |
| 7 | + |
| 8 | +--- |
| 9 | +It's possible to configure the BFF via IConfiguration. |
| 10 | + |
| 11 | +```csharp {6} |
| 12 | + |
| 13 | +var bffConfig = new ConfigurationBuilder() |
| 14 | + .AddJsonFile(Path.Combine(AppContext.BaseDirectory, "..", "..", "..", "BffConfig.json"), optional: false, reloadOnChange: true) |
| 15 | + |
| 16 | +services |
| 17 | + .AddBff() |
| 18 | + .LoadConfiguration(bffConfig); |
| 19 | + |
| 20 | +``` |
| 21 | + |
| 22 | +The configuration supports dynamic reloading (so any new frontend added / removed is immediately reflected). |
| 23 | + |
| 24 | +### BffConfiguration |
| 25 | + |
| 26 | +- **defaultOidcSettings** |
| 27 | + OIDC settings applied globally to all frontends unless overridden. |
| 28 | + Type: OidcConfiguration object (see below for properties). |
| 29 | + |
| 30 | +- **defaultCookieSettings** |
| 31 | + Cookie settings applied globally to all frontends unless overridden. |
| 32 | + Type: CookieConfiguration object (properties depend on your implementation). |
| 33 | + |
| 34 | +- **frontends** |
| 35 | + Dictionary of frontend configurations. |
| 36 | + Each key is a frontend name, and the value is a BffFrontendConfiguration object (see below). |
| 37 | + |
| 38 | +--- |
| 39 | + |
| 40 | +### BffFrontendConfiguration JSON Properties |
| 41 | + |
| 42 | +- **indexHtmlUrl** |
| 43 | + The URL to the main HTML file for this frontend. |
| 44 | + Example: `"https://localhost:5005/static/index.html"` |
| 45 | + |
| 46 | +- **matchingPath** |
| 47 | + The path prefix for requests routed to this frontend. |
| 48 | + Example: `"/from-config"` |
| 49 | + |
| 50 | +- **matchingOrigin** |
| 51 | + The origin to match for this frontend. |
| 52 | + Example: `"https://localhost:5005"` |
| 53 | + |
| 54 | +- **oidc** |
| 55 | + OIDC settings specific to this frontend. |
| 56 | + Type: OidcConfiguration object (see below). |
| 57 | + |
| 58 | +- **cookies** |
| 59 | + Cookie settings specific to this frontend. |
| 60 | + Type: CookieConfiguration object (see below) |
| 61 | + |
| 62 | +- **RemoteApis** |
| 63 | + Remote api's for this frontend. (see below) |
| 64 | + |
| 65 | +### RemoteApiConfiguration JSON Properties |
| 66 | + |
| 67 | +- **localPath** |
| 68 | + String. The local path that will be used to access the remote API. |
| 69 | + Example: `"/api/user-token"` |
| 70 | + |
| 71 | +- **targetUri** |
| 72 | + String. The target URI of the remote API. |
| 73 | + Example: `"https://localhost:5010"` |
| 74 | + |
| 75 | +- **requiredTokenType** |
| 76 | + String. The token requirement for accessing the remote API. |
| 77 | + Possible values: `"User"`, `"Client"`, `"None"`, `"OptionalUserOrClient"`, `"OptionalUserOrNone"` |
| 78 | + Default: `"User"` |
| 79 | + |
| 80 | +- **tokenRetrieverTypeName** |
| 81 | + String. The type name of the access token retriever to use for this remote API. |
| 82 | + |
| 83 | +- **userAccessTokenParameters** |
| 84 | + Object. Parameters for retrieving a user access token (see below). |
| 85 | + |
| 86 | +- **activityTimeout** |
| 87 | + String. How long a request is allowed to remain idle between operations before being canceled. |
| 88 | + Use C# `TimeSpan` serialization format, e.g. `"00:01:40"` for 100 seconds. |
| 89 | + |
| 90 | +- **allowResponseBuffering** |
| 91 | + Boolean. Allows write buffering when sending a response back to the client (if supported by the server). |
| 92 | + Note: Enabling this can break server-sent events (SSE) scenarios. |
| 93 | + |
| 94 | +--- |
| 95 | + |
| 96 | +### UserAccessTokenParameters JSON Properties |
| 97 | + |
| 98 | +- **signInScheme** |
| 99 | + String. The scheme used for signing in the user (typically the cookie authentication scheme). |
| 100 | + Example: `"Cookies"` |
| 101 | + |
| 102 | +- **challengeScheme** |
| 103 | + String. The authentication scheme to be used for challenges. |
| 104 | + Example: `"OpenIdConnect"` |
| 105 | + |
| 106 | +- **forceRenewal** |
| 107 | + Boolean. Whether to force renewal of the access token. |
| 108 | + |
| 109 | +- **resource** |
| 110 | + String. The resource for which the access token is requested. |
| 111 | + Example: `"https://api.example.com"` |
| 112 | + |
| 113 | + |
| 114 | +### OidcConfiguration JSON Properties |
| 115 | + |
| 116 | +- **clientId** |
| 117 | + The client ID of the OpenID Connect client. |
| 118 | + |
| 119 | +- **clientSecret** |
| 120 | + The client secret of the OpenID Connect client. |
| 121 | + |
| 122 | +- **callbackPath** |
| 123 | + The path or URI to which the OpenID Connect client will redirect after authentication. |
| 124 | + |
| 125 | +- **authority** |
| 126 | + The authority URI, typically the issuer or identity provider endpoint. |
| 127 | + |
| 128 | +- **responseType** |
| 129 | + The response type that the OpenID Connect client will request. |
| 130 | + |
| 131 | +- **responseMode** |
| 132 | + The response mode that the OpenID Connect client will use to return the authentication response. |
| 133 | + |
| 134 | +- **mapInboundClaims** |
| 135 | + Boolean. Whether to map inbound claims from the OpenID Connect provider to the user's claims in the application. |
| 136 | + |
| 137 | +- **saveTokens** |
| 138 | + Boolean. Whether to save the tokens received from the OpenID Connect provider. |
| 139 | + |
| 140 | +- **scope** |
| 141 | + Array of strings. The scopes that the OpenID Connect client will request from the provider. |
| 142 | + |
| 143 | +- **getClaimsFromUserInfoEndpoint** |
| 144 | + Boolean. Whether to retrieve claims from the UserInfo endpoint of the OpenID Connect provider. |
| 145 | + |
| 146 | +### CookieConfiguration JSON Properties |
| 147 | + |
| 148 | +- **httpOnly** |
| 149 | + Boolean. Indicates whether the cookie is inaccessible by client-side script. Defaults to true. |
| 150 | + |
| 151 | +- **sameSite** |
| 152 | + String. The SameSite attribute of the cookie. Defaults to strictg. |
| 153 | + Possible values: `"None"`, `"Lax"`, `"Strict"` |
| 154 | + |
| 155 | +- **securePolicy** |
| 156 | + String. The policy used to determine if the cookie is sent only over HTTPS. |
| 157 | + Possible values: `"Always"`, `"None"`, `"SameAsRequest"` |
| 158 | + |
| 159 | +- **name** |
| 160 | + String. The name of the cookie. |
| 161 | + |
| 162 | +- **maxAge** |
| 163 | + String. The max-age for the cookie. |
| 164 | + Example: "0:01:00 for 1 minute |
| 165 | + |
| 166 | +- **path** |
| 167 | + String. The cookie path. The BFF will configure the default values for this property. |
| 168 | + Example: `"/"` |
| 169 | + |
| 170 | +- **domain** |
| 171 | + String. The domain to associate the cookie with. The BFF will configure the default values for this property. |
| 172 | + Example: `"example.com"` |
| 173 | + |
| 174 | +### Example |
| 175 | + |
| 176 | +```json |
| 177 | +{ |
| 178 | + "defaultOidcSettings": { |
| 179 | + "clientId": "global-client", |
| 180 | + "authority": "https://login.example.com" |
| 181 | + }, |
| 182 | + "defaultCookieSettings": null, |
| 183 | + "frontends": { |
| 184 | + "some_frontend": { |
| 185 | + "indexHtmlUrl": "https://localhost:5005/static/index.html", |
| 186 | + "matchingPath": "/from-config", |
| 187 | + "oidc": { |
| 188 | + "clientId": "frontend1-client", |
| 189 | + "scope": ["openid", "profile", "email"] |
| 190 | + } |
| 191 | + } |
| 192 | + } |
| 193 | +} |
0 commit comments