From 0dd6d33093ca485d11ae689de97d45ff2d6b1f02 Mon Sep 17 00:00:00 2001 From: Geoffroy Couprie Date: Fri, 1 Sep 2023 12:01:03 +0200 Subject: [PATCH] remove mentions of router service level rhai We'll add it back once that feature is merged --- docs/source/configuration/authorization.mdx | 33 --------------------- 1 file changed, 33 deletions(-) diff --git a/docs/source/configuration/authorization.mdx b/docs/source/configuration/authorization.mdx index 1a21b54a1c..1b6d1e47f8 100644 --- a/docs/source/configuration/authorization.mdx +++ b/docs/source/configuration/authorization.mdx @@ -140,39 +140,6 @@ claims = context["apollo_authentication::JWT::claims"] claims["scope"] = "scope1 scope2 scope3" ``` - - -If the `apollo_authentication::JWT::claims` object holds scopes in another format, for example, an array of strings, or at a key other than `"scope"`, you can edit the claims with a [Rhai script](../customizations/rhai). - -The example below extracts an array of scopes from the `"roles"` claim and reformats them as a space-separated string. - -```Rhai -fn router_service(service) { - let request_callback = |request| { - let claims = request.context["apollo_authentication::JWT::claims"]; - let roles = claims["roles"]; - - let scope = ""; - if roles.len() > 1 { - scope = roles[0]; - } - - if roles.len() > 2 { - for role in roles[1..] { - scope += ' '; - scope += role; - } - } - - claims["scope"] = scope; - request.context["apollo_authentication::JWT::claims"] = claims; - }; - service.map_request(request_callback); -} -``` - - - #### Usage To use the `@requiresScopes` directive in a subgraph, you can [import it from the `@link` directive](/federation/federated-types/federated-directives/#importing-directives) like so: