Skip to content

Instantly share code, notes, and snippets.

View gregjbrown's full-sized avatar

Greg Brown gregjbrown

  • London, United Kingdom
View GitHub Profile
@gregjbrown
gregjbrown / app.yaml
Last active September 29, 2022 13:57
Deploy OPA to Azure Container Apps
type: Microsoft.App/containerApps
properties:
managedEnvironmentId: <opa-ca-env>
configuration:
activeRevisionsMode: Multiple
ingress:
allowInsecure: false
external: true
targetPort: 8181
transport: Auto
@gregjbrown
gregjbrown / apim_gateways
Last active October 27, 2022 17:42
Azure APIM rules
{
"<dev-instance>.azure-api.net": {
"environment": "development"
},
"<prod-instance>.azure-api.net": {
"environment": "production"
}
}
@gregjbrown
gregjbrown / policy.cshtml
Created October 27, 2022 16:46
Azure APIM policy.cshtml
<policies>
<inbound>
<base />
<set-variable name="requestId" value="@(context.RequestId)" />
<set-variable name="serviceName" value="@(context.Deployment.ServiceName)" />
<set-variable name="originalUrl" value="@(context.Request.OriginalUrl.ToString())" />
<set-variable name="authorization" value="@(context.Request.Headers.GetValueOrDefault("Authorization"))" />
<set-variable name="uriSegments" value="@(JsonConvert.SerializeObject(new Uri(context.Request.Url.ToString()).Segments))" />
<choose>
<when condition="@((bool)context.Request.HasBody)">
@gregjbrown
gregjbrown / backends
Created October 27, 2022 17:38
Azure APIM backends policy
{
"conferenceapi-dev.azurewebsites.net": {
"environment": "development"
},
"conferenceapi.azurewebsites.net": {
"environment": "production"
}
}
@gregjbrown
gregjbrown / rules.rego
Last active November 11, 2022 21:52
Azure APIM policy
package rules
import future.keywords.if
default allow = false
# allow everything unless denied
allow if not deny
# deny feedback posts without a valid JWT