If you are using products from Styra, the creators of Open Policy Agent, to help you streamline and scale your authorization needs, then you need Styra VS Code Tools. This extension integrates features from Styra products directly with your VS Code editor.
Ever wanted to know what impact your policy changes will have on your existing deployment without needing to deploy them? With the Enterprise OPA preview feature, you can see what decision will be made in the context of your live policy agent, all without effecting the current decisions it is making. With Styra VS Code Tools, you can run previews directly from VS Code using single-click Code Lens support, right-click contextual menus in Rego files, or via the command palette.
Enterprise OPA: Preview
- Preview the default query with any locally authored updatesEnterprise OPA: Preview Package
- Preview the package of the current file with any locally authored updatesEnterprise OPA: Preview Selection
- Preview the currently selected text with any locally authored updatesEnterprise OPA: Set Token
- Store the bearer token as a secret for use when authorizing Enterprise OPA preview requests
Setting | Default | Description |
---|---|---|
Opa > Roots |
[${workspaceFolder}] | Bundle roots to search when looking for Rego policies and data (inherited from the Open Policy Agent extension). |
Enterprise OPA > Url |
http://localhost:8181 | The URL where the Enterprise OPA HTTP API is accessible. |
Enterprise OPA > Preview > Default Query |
The default query to run when performing an Enterprise OPA: Preview. | |
Enterprise OPA > Preview > Prefix |
A prefix to add to all policy paths when mapping for Enterprise OPA preview. | |
Enterprise OPA > Preview > Arguments |
[] | Controls the behavior and features of Enterprise OPA preview calls. |
Enterprise OPA > Preview > Strategy |
all | Determine which files to map for Enterprise OPA preview calls. |
Enterprise OPA > Preview > Ignore |
[] | A set of glob patterns to omit when mapping for Enterprise OPA preview calls. |
Enterprise OPA > Preview > Code Lens |
true | Enable or disable support for Enterprise OPA preview Code Lens links. |
Enterprise OPA > Auth > Type |
none | Determine what kind of authorization to use when connecting to the Enterprise OPA API |
Enterprise OPA > Auth > Client Cert Pem |
A file path to a PEM encoded client certificate used for TLS authentication. | |
Enterprise OPA > Auth > Client Key Pem |
A file path to a PEM encoded client key used for TLS authentication. | |
Enterprise OPA > Auth > Client Cert CA |
A file path to a PEM encoded custom certificate authority certificate to trust when connecting to Enterprise OPA. | |
Enterprise OPA > Auth > Allow Unauthorized TLS |
false | Whether or not to trust Enterprise OPA when the returned TLS certificate is from an unknown authority. |
Styra Link is an opinionated workflow for managing Styra DAS. You can write, test, validate, and publish policy all within your normal development workflow. Styra VS Code Tools brings the capabilities of Styra Link right into VS Code, streamlining your policy authoring process even further.
Some of these commands execute immediately but those with a trailing ellipsis ask you to enter several inputs. When you see the footnote indicator next to the prompt (*) See output pane (*)
look for the latest footnote in the Styra output pane to provide further context on what you need to supply.
Styra Link: Bundle Update...
— update the local bundle with any current changes.Styra Link: Configure Git...
— configure Styra Link with a Git connection.Styra Link: Initialize...
— create (or connect to) a system in DAS.Styra Link: Search...
— find available library rules for the current Styra Link project.Styra Link: Test
— run your unit tests using the latest authored policies.Styra Link: Validate Compliance
— check for compliance violations against your latest authored polices for supported systems.Styra Link: Validate Decisions
— replay prior decisions against your latest authored polices to see how decisions will change.
Setting | Default | Description |
---|---|---|
Styra > Check Update Interval |
1 | How often to check for updates to the Styra CLI (in days). |
Styra > Diagnostic Limit |
120 | Length limit of diagnostic output (use -1 for no limit). |
Styra > Diagnostic Output |
false | Reveal API calls and other diagnostic details in the output pane. |
Styra > Output Format |
table | Selects the output format for commands that return data. |
- Styra CLI executable (
styra
) must be installed on your$PATH
. If you do not have Styra CLI installed, the plugin will prompt you to install it when you run any Styra Link command. - A Styra DAS tenant; you can get one for free at our Sign-up page; the VSCode plugin will check for this when you run any command; if not found, it will offer to take you to the same URL so you can get one. It only takes a moment!
New to Rego? Styra VS Code Tools provides a wealth of ready-made policy snippets to jump start your Rego journey. Our general language snippets as well to aid you in getting up to speed with rego. All of these start with "rego" as the trigger, so just type that into a rego file and you will see a list of them.
In addition to the general snippets, Styra VS Code Tools contains over 120 snippets defined for the Styra DAS Kubernetes system type.
For questions, discussions and announcements related to Styra products, services and open-source projects, please join the Styra community on Slack!