-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
prompt Fields no reachable #243
Comments
@DrummyFloyd if you open the network tab of your browser, when you edit a prompt stage you'll see a request to I'd love to have the data source too! |
Until this issue is closed you can recreate the fields you need with something like: resource "authentik_stage_prompt" "user_data" {
name = "enrollment-user-data-prompt"
fields = [
authentik_stage_prompt_field.username.id,
authentik_stage_prompt_field.name.id,
authentik_stage_prompt_field.email.id,
authentik_stage_prompt_field.password.id,
authentik_stage_prompt_field.password_repeat.id,
]
}
resource "authentik_stage_prompt_field" "username" {
field_key = "username"
label = "Username"
type = "text"
order = 200
placeholder = <<EOT
try:
return user.username
except:
return ''
EOT
placeholder_expression = true
required = true
# Until https://github.com/goauthentik/terraform-provider-authentik/issues/298 is fixed
lifecycle {
ignore_changes = [
placeholder,
]
}
}
resource "authentik_stage_prompt_field" "name" {
field_key = "name"
label = "Name"
type = "text"
order = 201
placeholder = <<EOT
try:
return user.name
except:
return ''
EOT
placeholder_expression = true
required = true
# Until https://github.com/goauthentik/terraform-provider-authentik/issues/298 is fixed
lifecycle {
ignore_changes = [
placeholder,
]
}
}
resource "authentik_stage_prompt_field" "email" {
field_key = "email"
label = "Email"
type = "email"
order = 202
placeholder = <<EOT
try:
return user.email
except:
return ''
EOT
placeholder_expression = true
required = true
# Until https://github.com/goauthentik/terraform-provider-authentik/issues/298 is fixed
lifecycle {
ignore_changes = [
placeholder,
]
}
}
resource "authentik_stage_prompt_field" "password" {
field_key = "password"
label = "Password"
type = "password"
order = 300
placeholder = "Password"
placeholder_expression = false
required = true
}
resource "authentik_stage_prompt_field" "password_repeat" {
field_key = "password_repeat"
label = "Password (repeat)"
type = "password"
order = 301
placeholder = "Password (repeat)"
placeholder_expression = false
required = true
} |
thank you for your help , 'ive managed to do something similar ^^ will try to contribute asap |
Hello! My workaround for this is dumping data in YAML format to files. These files can then be used directly in Terraform scripts. def _dump_fields(rctx, bcfg):
response = _request_get(rctx, "stages/prompt/prompts/", None)
body = None
if response is not None and response.status_code == 200:
body = response.json()['results']
body_yaml = yaml.dump(body)
filename = f"{rctx.obj.config_name}_authentik_prompts.yaml"
with open(f"{rctx.obj.config_dir}/{filename}", "w") as f:
f.write(body_yaml)
elif response is not None:
raise Exception(f"Status code is not OK. Response - {response}")
def _request_get(rctx, path, params):
root_config = rctx.obj.config # context of execution, constructed by click (Python library for CLI)
root_secrets = rctx.obj.secrets # the same
secrets = root_secrets["authentik"]
acfg = root_config["authentik"]
baseUrl = acfg["base_url"].format(protocol=acfg["protocol"], host=acfg["external_host"], port=acfg["external_port"])
url = baseUrl + path
headers = Headers
requestTimeout = acfg["request_timeout"]
headers["Authorization"] = headers["Authorization"].format(token=secrets["admin_token"])
response = requests.get(url, timeout=requestTimeout, params=params, headers=headers)
return response Then in Terraform: locals {
auth_prompts = yamldecode(file("../../configs/${var.deployment_env}_authentik_prompts.yml"))
}
resource "authentik_stage_prompt" "sb-enrollment" {
name = authentik_flow.enrollment.name
fields = [
for prompt in local.auth_prompts : prompt.pk
if prompt.field_key == "username" || prompt.field_key == "email" || prompt.field_key == "password" || prompt.field_key == "password-repeat"
]
} You can use |
Hi ,
would be great to have a
data "authentik_prompt_fields"
at i don't know how to get
UUID
of existingprompt field
another suggestion would be great to modify existing stage with terraform, instead of creating quasi same stage , with only one difference.
john
The text was updated successfully, but these errors were encountered: