Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add active directory policy #23

Merged
merged 13 commits into from
May 12, 2021
5 changes: 4 additions & 1 deletion code/api.tf
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,10 @@ module "apim_backoffice_api" {

content_value = file("./backoffice_api/swagger.json")

xml_content = file("./backoffice_api/policy.xml")
xml_content = templatefile("./backoffice_api/policy.xml.tpl", {
openid_config_url = var.adb2c_openid_config_url
audience = var.adb2c_audience
})
}

module "apim_spid_login_api" {
Expand Down
8 changes: 0 additions & 8 deletions code/backoffice_api/policy.xml

This file was deleted.

17 changes: 17 additions & 0 deletions code/backoffice_api/policy.xml.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<policies>
<inbound>
<base />
<validate-jwt header-name="Authorization" failed-validation-httpcode="401" require-expiration-time="true" require-scheme="Bearer" require-signed-tokens="true" >
<openid-config url="${openid_config_url}" />
<audiences>
<audience>${audience}</audience>
</audiences>
</validate-jwt>
<set-header name="X-CGN-USER-ROLE" exists-action="override">
<value>ROLE_ADMIN</value>
</set-header>
</inbound>
<outbound>
<base />
</outbound>
</policies>
11 changes: 11 additions & 0 deletions code/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,14 @@ variable "enable_ade_aa_mock" {
type = bool
default = false
}

## AD B2C
variable "adb2c_openid_config_url" {
type = string
description = "Azure AD B2C OpenID Connect metadata document"
}

variable "adb2c_audience" {
type = string
description = "recipients that the JWT is intended for"
}
16 changes: 16 additions & 0 deletions vars/dev.tf
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,19 @@ resource "tfe_variable" "dev_enable_ade_aa_mock" {
}



resource "tfe_variable" "dev_adb2c_openid_config_url" {
key = "adb2c_openid_config_url"
value = "https://testcgnportalbitrock.b2clogin.com/testcgnportalbitrock.onmicrosoft.com/B2C_1_LOGIN/v2.0/.well-known/openid-configuration"
category = "terraform"
sensitive = true
workspace_id = data.tfe_workspace.dev.id
}

resource "tfe_variable" "dev_adb2c_audience" {
key = "adb2c_audience"
value = "5f75f12e-b5a0-4656-b0ff-334bb9d4222f"
category = "terraform"
sensitive = true
workspace_id = data.tfe_workspace.dev.id
}
16 changes: 16 additions & 0 deletions vars/uat.tf
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,19 @@ resource "tfe_variable" "uat_enable_ade_aa_mock" {
category = "terraform"
workspace_id = data.tfe_workspace.uat.id
}

resource "tfe_variable" "uat_adb2c_openid_config_url" {
key = "adb2c_openid_config_url"
value = "https://cgnonboardingportaluat.b2clogin.com/cgnonboardingportaluat.onmicrosoft.com/B2C_1_login/v2.0/.well-known/openid-configuration"
category = "terraform"
sensitive = true
workspace_id = data.tfe_workspace.uat.id
}

resource "tfe_variable" "uat_adb2c_audience" {
key = "adb2c_audience"
value = "2416d411-9cbb-4d4c-a902-2570f031b9f0"
category = "terraform"
sensitive = true
workspace_id = data.tfe_workspace.uat.id
}