Skip to main content

Git for JSON Object Import Data Source

Another option for making JSON data available to policies is to store that data in a Git repository and use a special data source that automatically reads the JSON out of the Git repository. For example, distributing those policies to OPA and evaluating those policies.

Configure through the DAS GUI

The following section helps you to configure to access a data stored in Git repository using the DAS GUI.

Create a DAS System

Go to <das-id> To add a new system, click the + next to SYSTEMS on the left side of the navigation panel.

Fill in the following fields:

  • System type (required): Select any system type from the drop down list. For example, Custom.

  • System name (required): A human-friendly name so that you can distinguish between the different systems.

  • Description (optional): More details about this system.

  • Leave the Show errors switch ON to display the errors.

  • Click Add system button.

Now, your DAS system is created under the SYSTEMS on the left side of the navigation panel.

Add a Data Source

After you create your system, click the three dots (⋮) next to it and select Add Data Source to start configuring the data source.

Figure 1 - Add Data Source

Now, your Custom System >> Add Data Source dialog appears.

Figure 2 - Add Data Source Window

Do the following actions in your Custom System >> Add Data Source dialog box.

  1. Type: An editable data source that you fill in with JSON data and publish. Click the down arrow to select the data source type. For example, select Git for JSON Object Import to pull a JSON object from Git. This refreshes regularly.

    Figure 3 - Data Source Type

  2. Path: Enter a new or existing path separated by /. For example, am/datasourcetypes.

  3. Data source name (required): Enter a name for the data source type. For example, am-git-for-json-object-import.

  4. Description: This field is optional.

  5. Git authentication: Styra DAS supports either HTTPS or SSH authentication for Git. For example, select HTTPS.

  6. Git repository (required): The subdirectory where you want to save the policies. Enter the Git repository. For example,

  7. Access credentials (required): Enter the access credentials. If the Access key and secret already exist then click the Update access key button.

  8. Reference: Specify a tag or branch reference. For example, refs/heads/master.

  9. Repository path: Enter a relative path within the given repository. For example, example.json.

  10. Refresh interval: Enter a refresh interval which is the amount of time between polling intervals. Default is s.

  11. Click the arrow to expand the Advanced field.

  12. Data transform: Specify a policy and write a query that allows you to apply Rego transformations before it is persisted as data. For example, Select Custom and fill in the following fields:

    • Policy: An existing policy separated by /. For example, transform/transform.rego.

    • Rego query: Path to the Rego rule to evaluate. For example, data.transform.query.

  13. Leave the Enable on-premise data source agent switch OFF. Enable on-premise data source agent shows how and where to run the data source. If set to true then datasource-agent will run on premise setup, otherwise on SaaS.

Now, make sure you filled all the fields similar to Figure 5.

Figure 4 - Verify the Data Source Form

  1. Finally, click the Add button to add a data source.

The following shows an example output which appears after the data source is created in DAS.