Skip to main content

Protect applications and APIs with policies using dynamic scopes

Instructions on how to configure a policy verifying dynamic scopes and use them as an authorization asset.

Among multiple ways of creating policies in SecureAuth, the one using explicit names of scopes has its dynamic variation now. SecureAuth enables you to define policies using dynamic scopes. For more information on dynamic scopes, see Creating and Configuring Dynamic Scopes.

Purpose​

Define your policies more efficiently with the use of dynamic scopes.

Prerequisites​

  • You have login credentials to the SecureAuth administrator portal.

  • You have a dynamic scope defined in the SecureAuth administrator portal.

Create Policy​

SecureAuth Policy​

  1. Create a SecureAuth policy as explained in Creating SecureAuth policies in the Visual Policy Editor.

  2. In the policy editor, select + to add a validator.

    The policy editor with the Add validator button highlighted

  3. In the Add new validator view, select the Attributes validator.

    The Add new validator pane with the Attributes validator highlighted

  4. In the Attributes view, select ADD FIELD.

    The Attributes validator pane with no attributes and the Add field link highlighted

  5. In the Cross context condition editor, expand the Source dropdown menu.

    The Cross context condition editor with the Source dropdown highlighted

  6. From the Source dropdown menu, select Scopes.

    The Source dropdown with Scopes highlighted among the data source contexts

  7. In the Cross context condition editor, expand the Field / Attribute dropdown menu.

    The Cross context condition editor with the empty Field / Attribute dropdown for the Scopes context

  8. From the Field / Attribute dropdown menu, select a dynamic-scope attribute, for example, get user.

    The Field / Attribute dropdown listing scopes, with the get user dynamic scope highlighted

  9. In the Cross context condition editor, expand the Parameter dropdown menu.

    The Cross context condition editor with get user selected and the Parameter dropdown highlighted

  10. From the Parameter dropdown menu, select a parameter value pattern, for example, params.0.

    The Parameter dropdown with params.0 highlighted

  11. Select an operator (for example, equals) to establish the relationship between the source and the target (the two building blocks of your scope definition).

    The operator options with equals highlighted

  12. In the Cross context condition editor, expand the Target dropdown menu.

    The equals operator selected, with the Target dropdown highlighted

  13. From the Target dropdown menu, select a data target context, for example, Custom value.

    The Target dropdown with Custom value highlighted

  14. Specify the value for your target argument (for example, 1) in the filed provided.

    The Custom value field set to 1

  15. Select SAVE to proceed.

    The completed cross context condition with the Save button highlighted

  16. In the Attributes view, select the OK icon to complete the validator setup.

    The Attributes pane showing scopes.users.*.params.0 equals 1, with the OK icon highlighted

  17. In the policy editor, select SAVE to proceed.

    The policy editor showing the Attributes validator, with the Save button highlighted

    Result: Your SecureAuth policy using a dynamic scope is ready.

Rego Policy​

  1. Create a Rego policy as explained in Protecting Applications and APIs in SecureAuth Using Open Policy Agent.

    The policy editor opens and allows you to configure your policy in two ways:

    • Entering your code manually (1)

    • Selecting the predefined policy template OAuth Dynamic Scope check (2)

    The Rego policy editor with the Definition code area and the Example OPA policies list

    note

    For purposes of this article, the OAuth Dynamic Scope check template has been adopted.

  2. In the policy editor, select the predefined policy template OAuth Dynamic Scope check.

    The Example OPA policies list with OAuth Dynamic Scope check highlighted

  3. Select YES to confirm that you want to import the exemplary policy.

    The Import Example Policy dialog asking to replace the current policy, with Yes and Cancel buttons

    Result: The Definition view of the policy editor gets populated with a sample code using the dynamic scope syntax. Now is your turn to modify variables and parameters so that the policy addresses your specific scopes.

    The Definition view populated with the sample dynamic scope Rego code

  4. In the Definition view of the policy editor, modify the sample code to include your dynamic scope data.

    The Definition view with the sample code modified for a custom dynamic scope

  5. Select SAVE to finalize your policy.

    The Rego policy editor with the Save button highlighted

    Result: Your Rego policy using a dynamic scope is ready.