{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["admonition"]},"redocly_category":"Guides","product":"Identity Management","type":"markdown"},"seo":{"title":"Implement the authorization model","description":"Everything about Mosaic Journeys, SDKs, and APIs","siteUrl":"https://developer.transmitsecurity.com"},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"implement-the-authorization-model","__idx":0},"children":["Implement the authorization model"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This guide shows how to configure Resource-Aware Authorization in Mosaic and how to request it on a token. For how the model works, see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/how_authorization_works"},"children":["How authorization works"]},"."]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Deprecation notice"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you already use tenant-wide resources, migrate them to the new authorization model. See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#migrate-from-tenant-wide-resources"},"children":["Migrate from tenant-wide resources"]},"."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Applying the model has four stages:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Build the model:"]}," Create one inventory of resources, scopes, permissions, and roles for each Mosaic application. (Steps 1-3)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Assign authorization:"]}," Assign resources and scopes to clients, and assign roles to users. (Steps 4-5)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Authorize the request:"]}," The client requests a resource and scopes. Mosaic returns an access token that contains only the authorization granted for that request. (Step 6)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Enforce authorization:"]}," Your API ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/validate_tokens"},"children":["validates the token"]}," and checks the audience, scope, and permissions before it performs an action. (Step 7)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"default-authorization","__idx":1},"children":["Default authorization"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When you create a Mosaic app, it has no access controls configured. You can sign users in before you create resources, permissions, or custom scopes. Mosaic still returns access tokens and these tokens include basic authorization:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," is ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["userid-api"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Token lifetimes come from the client's token timeout settings."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Reserved scopes that the client requests, such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid"]},", are included."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"before-you-start","__idx":2},"children":["Before you start"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If this is your first time integrating with Mosaic, create a Mosaic application in the Admin Portal as described ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/create_new_application"},"children":["here"]}," and add an OIDC-based ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["User authentication client"]}," skipping resource and scope selection (see ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/configure_oidc_client"},"children":["Configure OIDC clients"]},"), then implement a login for your app."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-1-plan-your-strategy","__idx":3},"children":["Step 1: Plan your strategy"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Before you create anything in the Admin Portal, decide what the application needs to protect and who may do what."]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["List the APIs that need their own token. Each API is a resource."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["List the actions a user may perform. An action that belongs to one API is a permission on that resource. An action that applies no matter which API is called is a global permission."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["List the privileges a client may request. Each privilege is a scope, either global or owned by one resource."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Group the permissions into user roles."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Decide which clients may request each resource, and which scopes each client may receive."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can create resources and scopes and leave them unassigned but a client cannot request scopes and resources it doesn't have."]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Item"},"children":["Item"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"What you will create"},"children":["What you will create"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resources"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping cart (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/cart"]},"), Payments (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/payments"]},"), and Inventory (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/inventory"]},")"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Global permission"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]},", so a user can browse the catalog on any token"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Global scope"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]},", so the client can request catalog access with any resource"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping cart permissions"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["update-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping cart scopes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:write"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:checkout"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Payments permissions"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["approve-payment"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Payments scopes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Roles"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopper and Store manager"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Storefront client"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping cart and Payments, not Inventory. Scopes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:write"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:checkout"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In this example, ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}," stays off the storefront client. Inventory is created so a later request can ask for a resource the storefront is not assigned."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-2-create-resources-permissions-and-scopes","__idx":4},"children":["Step 2: Create resources, permissions, and scopes"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge-wrapper"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge"},"children":["Admin Portal"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["In the Admin Portal, navigate to your Mosaic app > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Resources"]},". Create one resource for each API you identified. When creating a resource, add the permissions and scopes that belong to that resource before you save. A permission or scope created here is owned by the resource. Under ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Session management"]},", set how long access to this resource lasts–use a shorter access token for a more sensitive resource:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access token expiration"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Refresh token expiration"]},". Won't apply if the authorization request includes two or more resources. In this case, refresh token expiration time derives from the client settings."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Session expiration"]},", the maximum period of time the refresh token can be rotated for this resource. Won't apply if the authorization request includes two or more resources. In this case, maximum rotation time derives from the client settings."]}]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create global permissions from ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Permissions"]},", and leave them unassigned to a resource. A global permission can appear on a token for any API."]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create global scopes from ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Scopes"]},", and leave them unassigned to a resource. A client can request a global scope with any resource."]}]}]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the shopping cart resource:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopping cart"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource URI"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/cart"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Access token expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["3600 (1 hour)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Refresh token expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["1209600 (14 days)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Session expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["2592000 (30 days)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Permissions"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["update-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Scopes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:write"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:checkout"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Save the resource, then create the payments resource the same way:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Payments"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource URI"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/payments"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Access token expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["900 (15 minutes)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Refresh token expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["86400 (1 day)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Session expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["86400 (1 day)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Permissions"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["approve-payment"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Scopes"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create the inventory resource with no permissions or scopes. It won't be assigned to the storefront client."]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Field"},"children":["Field"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource name"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Inventory"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Resource URI"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/inventory"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Access token expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["28800 (8 hours)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Refresh token expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["604800 (7 days)"]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Session expiration"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["604800 (7 days)"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]}," from ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Permissions"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Create ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]}," from ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Scopes"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-3-define-user-roles","__idx":5},"children":["Step 3: Define user roles"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge-wrapper"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge"},"children":["Admin Portal"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Navigate to ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Roles"]},". Create each role and select permissions from the inventory. The role references permissions that already exist. A role can reference global permissions and resource-specific permissions."]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Role"},"children":["Role"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Permissions"},"children":["Permissions"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopper"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["update-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Store manager"]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["update-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["approve-payment"]}]}]}]}]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-4-assign-resources-and-scopes-to-the-client","__idx":6},"children":["Step 4: Assign resources and scopes to the client"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge-wrapper"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge"},"children":["Admin Portal"]}]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In your Mosaic app settings, proceed to the ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Clients"]}," tab and expand settings for a client that represents your app (OIDC-based user authentication client)."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["In ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]},", assign the resources that client may request, and assign the scopes it may request. A resource-specific scope can be assigned only when its resource is also assigned to the client. You do not have to assign every resource in the application."]}]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Open the storefront client. Assign the Shopping cart and Payments resources. Do not assign Inventory. Assign the scopes the client may request: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:write"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:checkout"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]},"."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Leave ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}," unassigned."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-5-assign-roles-to-users","__idx":7},"children":["Step 5: Assign roles to users"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge-wrapper"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge"},"children":["Admin Portal"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Assign each role to the users who should have it. A user access token includes the permissions from the roles assigned to that user, limited to the resource that was requested. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]}," claim lists every role assigned to the user."]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Assign the Shopper role to each shopper, and the Store manager role to each store manager."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-6-send-authorization-request","__idx":8},"children":["Step 6: Send authorization request"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge-wrapper"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge"},"children":["client"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The authorization request is where the client states the access it wants. The client sends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," to Mosaic together with the other parameters of the flow, completes the flow, and receives tokens. In the authorization code flow, that means exchanging the authorization code for tokens."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can send ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," on these flows:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_oidc"},"children":["Authorization code"]},", including ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_oidc_pkce"},"children":["PKCE"]}," and ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_oidc_par"},"children":["PAR"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_ciba"},"children":["CIBA"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_device"},"children":["Device authorization"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/retrieve_client_tokens"},"children":["Client credentials"]},", for a client access token. That token has no user permissions or roles."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/token_exchange"},"children":["Token exchange"]},", to retarget an existing user token at another resource. Mosaic recomputes the scope and permissions for that resource, and never grants ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["offline_access"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_offline"},"children":["Token refresh"]},", to exchange a refresh token for an access token for another resource from the same authorization request."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["You can send ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]}," on these flows utilizing Mosaic authentication APIs:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["OIDC-based ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_passwords"},"children":["Password login"]}," and backend-initiated ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/be_auth_passwords"},"children":["Password login"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["OIDC-based ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_email_magic_link"},"children":["Email magic link login"]}," and backend-initiated ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/be_auth_email_magic_link"},"children":["Email magic link login"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["OIDC-based ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_email_otp"},"children":["Email OTP login"]}," and backend-initiated ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/be_auth_email_otp"},"children":["Email OTP login"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/be_auth_totp"},"children":["TOTP login"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/be_auth_biometrics_android"},"children":["Mobile biometrics"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["etc."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"user-access-token","__idx":9},"children":["User access token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The example below uses the authorization code flow. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SCOPE"]}," is the URL-encoded list of scopes, and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RESOURCE_URI"]}," is the URL-encoded resource URI. Repeat ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]}," to request more than one resource."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mosaic checks each requested resource before the user logs in. If one is not assigned to the client, Mosaic redirects to the redirect URI with the ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid_target"]}," error."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"http","header":{"controls":{"copy":{}}},"source":"https://api.transmitsecurity.io/cis/oidc/auth?\n  client_id=CLIENT_ID&\n  scope=openid%20SCOPE&\n  response_type=code&\n  redirect_uri=REDIRECT_URI&\n  resource=RESOURCE_URI\n","lang":"http"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If every requested resource is assigned, the token request to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/oidc/token"]}," must specify a resource–pick one of the initially resources. If the initial request included one resource, it can be omitted at the token request. The ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," always targets a single resource."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.transmitsecurity.io/oidc/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=authorization_code \\\n  -d client_id=CLIENT_ID \\\n  -d client_secret=CLIENT_SECRET \\\n  -d code=CODE \\\n  -d redirect_uri=REDIRECT_URI \\\n  -d resource=RESOURCE_URI\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Upon a code exchange (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["oidc/token"]},"), Mosaic returns a user access token that includes:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," is the one resource picked on the token request."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," lists the requested scopes Mosaic granted: reserved scopes such as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid"]},", global scopes assigned to the client, and resource-specific scopes that belong to the requested resource and are assigned to the client. When the flow includes a ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_consent"},"children":["consent screen"]},", the user has to consent to granting these scopes as well."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," lists the global permissions on the user's roles, plus the resource-specific permissions on those roles that belong to the requested resource. Requested scopes do not filter permissions."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]}," lists every role assigned to the user."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For first-party clients, Mosaic omits a scope that belongs to another resource, a scope that is not assigned to the client, and a permission the user's roles do not include for that resource. In case of third-party clients, Mosaic denies the request entirely if one of the requested scopes cannot be granted in a token or the user didn't consent to requested scopes. ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-7-enforce-authorization"},"children":["Step 7"]}," describes how your API checks these claims."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Exchange the refresh token to obtain an access token for another resource from that authorization request. See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/auth_offline"},"children":["Refresh app's access"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.transmitsecurity.io/oidc/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=refresh_token \\\n  -d client_id=CLIENT_ID \\\n  -d client_secret=CLIENT_SECRET \\\n  -d refresh_token=REFRESH_TOKEN \\\n  -d resource=RESOURCE_URI\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A shopper signs in through the storefront. The authorization request asks for the shopping cart and inventory resources. The inventory resource is not assigned to the storefront."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"http","header":{"controls":{"copy":{}}},"source":"https://api.transmitsecurity.io/cis/oidc/auth?\n  client_id=CLIENT_ID&\n  scope=openid%20store:browse%20cart:read&\n  response_type=code&\n  redirect_uri=REDIRECT_URI&\n  resource=https%3A%2F%2Fapi.shop.example%2Fcart&\n  resource=https%3A%2F%2Fapi.shop.example%2Finventory\n","lang":"http"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mosaic redirects to the redirect URI with ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["invalid_target"]}," before the shopper logs in. No token is issued."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A later authorization request asks for the shopping cart and payments resources. Both are assigned to the storefront. The request includes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:write"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid"]}," is included because this is a user login. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["offline_access"]}," is included so Mosaic can return a refresh token. It is a reserved scope, so Mosaic grants it without an assignment on the client. Set ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["prompt"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["consent"]},", which is required to obtain a refresh token."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"http","header":{"controls":{"copy":{}}},"source":"https://api.transmitsecurity.io/cis/oidc/auth?\n  client_id=CLIENT_ID&\n  scope=openid%20offline_access%20store:browse%20cart:read%20cart:write%20payments:read%20payments:approve&\n  response_type=code&\n  prompt=consent&\n  redirect_uri=REDIRECT_URI&\n  resource=https%3A%2F%2Fapi.shop.example%2Fcart&\n  resource=https%3A%2F%2Fapi.shop.example%2Fpayments\n","lang":"http"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The code exchange at ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/oidc/token"]}," must pick one of those resources. This exchange picks the shopping cart resource:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.transmitsecurity.io/oidc/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=authorization_code \\\n  -d client_id=CLIENT_ID \\\n  -d client_secret=CLIENT_SECRET \\\n  -d code=CODE \\\n  -d redirect_uri=REDIRECT_URI \\\n  -d resource=https://api.shop.example/cart\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mosaic returns a user access token that includes:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Claim"},"children":["Claim"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/cart"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid offline_access store:browse cart:read cart:write"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["create-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["update-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopper"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]}," is included because it is a global scope assigned to the storefront and the client requested it. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]}," are included from the Shopper role. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]}," was not sent in the request. Requested scopes do not filter permissions."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The token leaves out what this client or this shopper cannot have. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}," are not in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]},", because they belong to the payments resource, not the shopping cart resource that was granted. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["delete-cart"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["approve-payment"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]}," are not in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]},". The cart API accepts this token. The payments API and the inventory API reject it."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The payments resource was also on the authorization request. Exchange the refresh token from this login to obtain an access token for that resource:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.transmitsecurity.io/oidc/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=refresh_token \\\n  -d client_id=CLIENT_ID \\\n  -d client_secret=CLIENT_SECRET \\\n  -d resource=https://api.shop.example/payments \\\n  -d refresh_token=REFRESH_TOKEN\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mosaic returns an access token for the payments resource:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Claim"},"children":["Claim"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/payments"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid offline_access store:browse payments:read"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopper"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]}," is included because it belongs to the payments resource, it is assigned to the storefront, and the authorization request included it. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}," is not in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]},", because it is not assigned to the storefront client. The cart scopes and cart permissions are absent because they belong to the shopping cart resource. The payments API accepts this token. The cart API and the inventory API reject it."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The same shopper can also start a new authorization request that asks only for the payments resource, with the scopes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:read"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"http","header":{"controls":{"copy":{}}},"source":"https://api.transmitsecurity.io/cis/oidc/auth?\n  client_id=CLIENT_ID&\n  scope=openid%20store:browse%20payments:read%20cart:read%20payments:approve&\n  response_type=code&\n  redirect_uri=REDIRECT_URI&\n  resource=https%3A%2F%2Fapi.shop.example%2Fpayments\n","lang":"http"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mosaic returns:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Claim"},"children":["Claim"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/payments"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["openid store:browse payments:read"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["browse-store"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":["Shopper"]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]}," is not in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]},", because it belongs to the shopping cart resource. ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}," is not in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]},", because it is not assigned the storefront client. The cart permissions are absent because they belong to the shopping cart resource. The payments API accepts this token. The cart API and the inventory API reject it."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":3,"id":"client-access-token","__idx":10},"children":["Client access token"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Client access tokens, such as tokens from the client credentials grant, follow the same audience and scope rules but exclude ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]},", because those come from roles assigned to a user."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A client credentials request sends ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/oidc/token"]},". ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["SCOPE"]}," is the space-separated list of scopes, and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RESOURCE_URI"]}," is the resource URI. A request to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["/oidc/token"]}," specifies one ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]}," value. There is no authorization code to exchange."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.transmitsecurity.io/oidc/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=client_credentials \\\n  -d client_id=CLIENT_ID \\\n  -d client_secret=CLIENT_SECRET \\\n  -d resource=RESOURCE_URI \\\n  -d scope=SCOPE\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A client credentials request for the storefront asks for the shopping cart resource and the scopes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse"]},", ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:read"]},", and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]},":"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"shell","header":{"controls":{"copy":{}}},"source":"curl -i -X POST \\\n  https://api.transmitsecurity.io/oidc/token \\\n  -H 'Content-Type: application/x-www-form-urlencoded' \\\n  -d grant_type=client_credentials \\\n  -d client_id=CLIENT_ID \\\n  -d client_secret=CLIENT_SECRET \\\n  -d resource=https://api.shop.example/cart \\\n  -d scope='store:browse cart:read payments:approve'\n","lang":"shell"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Mosaic returns a client access token that includes:"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"md-table-wrapper"},"children":[{"$$mdtype":"Tag","name":"table","attributes":{"className":"md"},"children":[{"$$mdtype":"Tag","name":"thead","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Claim"},"children":["Claim"]},{"$$mdtype":"Tag","name":"th","attributes":{"data-label":"Value"},"children":["Value"]}]}]},{"$$mdtype":"Tag","name":"tbody","attributes":{},"children":[{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/cart"]}]}]},{"$$mdtype":"Tag","name":"tr","attributes":{},"children":[{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}]},{"$$mdtype":"Tag","name":"td","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["store:browse cart:read"]}]}]}]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["payments:approve"]}," is not in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]},", because it belongs to the payments resource. The token does not include ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," or ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]},". The cart API accepts this token. The payments API and the inventory API reject it."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"step-7-enforce-authorization","__idx":11},"children":["Step 7: Enforce authorization"]},{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge-wrapper"},"children":[{"$$mdtype":"Tag","name":"div","attributes":{"className":"badge"},"children":["Backend"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/guides/user/validate_tokens"},"children":["Validate the access token"]}," before you use it. After validation succeeds, your API decides whether this call is allowed."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["On each call, check all of the following. Reject the call if any check fails:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," is this API's resource URI. Reject a token issued for another resource."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," includes the scope for this operation. A scope says the client may call the operation."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," includes the permission for this action. A permission says this user may perform the action. A requested scope does not replace this check."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Do not authorize from ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["roles"]}," alone. That claim lists every role assigned to the user, including roles that reference other resources. Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," for the decision."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A client access token has no user. Check ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," only."]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"b","attributes":{},"children":["Example: an online store"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Starting checkout on the cart API requires:"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," of ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["https://api.shop.example/cart"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["scope"]}," includes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["cart:checkout"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," includes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["checkout-cart"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A cart token is rejected by the payments API and the inventory API, because ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["aud"]}," is not their resource URI. A payments token that includes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["view-payment"]}," can view a payment. It cannot approve one unless ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["permissions"]}," also includes ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["approve-payment"]},"."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"migrate-from-tenant-wide-resources","__idx":12},"children":["Migrate from tenant-wide resources"]},{"$$mdtype":"Tag","name":"Admonition","attributes":{"type":"warning","name":"Deprecation notice"},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Tenant-wide resources and the APIs that manage them are being deprecated. Create resources in the Mosaic applications, and verify your integrations use a new model."]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["For your convenience, Mosaic has automatically migrated tenant-wide resources to the application level, with the resource naming preserved. In the Admin Portal, navigate to the Mosaic apps > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Access Control"]}," > ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Resources"]}," to confirm required resources are present. If an app-level resource is missing:"]},{"$$mdtype":"Tag","name":"ol","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Create an application resource for each tenant-wide resource your integration still uses. See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-2-create-resources-permissions-and-scopes"},"children":["Step 2"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Assign each new resource to the clients that should receive tokens for it. See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-4-assign-resources-and-scopes-to-the-client"},"children":["Step 4"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Update authorization requests to send the new resource URI as ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resource"]},". See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#step-6-send-authorization-request"},"children":["Step 6"]},"."]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Update Mosaic API calls that pass resource IDs. Send the ID of the application resource, not the tenant-wide resource. For example, ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/openapi/user/clients.openapi/other/createclient"},"children":["Create client"]}," takes those IDs in ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["resources"]},"."]}]},{"$$mdtype":"Tag","name":"style","attributes":{},"children":["\ntable th:first-of-type {\n    width: 25%;\n}\n"]}]},"headings":[{"value":"Implement the authorization model","id":"implement-the-authorization-model","depth":1},{"value":"Default authorization","id":"default-authorization","depth":2},{"value":"Before you start","id":"before-you-start","depth":2},{"value":"Step 1: Plan your strategy","id":"step-1-plan-your-strategy","depth":2},{"value":"Step 2: Create resources, permissions, and scopes","id":"step-2-create-resources-permissions-and-scopes","depth":2},{"value":"Step 3: Define user roles","id":"step-3-define-user-roles","depth":2},{"value":"Step 4: Assign resources and scopes to the client","id":"step-4-assign-resources-and-scopes-to-the-client","depth":2},{"value":"Step 5: Assign roles to users","id":"step-5-assign-roles-to-users","depth":2},{"value":"Step 6: Send authorization request","id":"step-6-send-authorization-request","depth":2},{"value":"User access token","id":"user-access-token","depth":3},{"value":"Client access token","id":"client-access-token","depth":3},{"value":"Step 7: Enforce authorization","id":"step-7-enforce-authorization","depth":2},{"value":"Migrate from tenant-wide resources","id":"migrate-from-tenant-wide-resources","depth":2}],"frontmatter":{"title":"Implement the authorization model","markdown":{"toc":{"depth":2}},"seo":{"title":"Implement the authorization model"}},"lastModified":"2026-11-22T13:32:43.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/guides/user/implement_authorization","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}