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

prompt Fields no reachable #243

Open
DrummyFloyd opened this issue Oct 14, 2022 · 3 comments
Open

prompt Fields no reachable #243

DrummyFloyd opened this issue Oct 14, 2022 · 3 comments

Comments

@DrummyFloyd
Copy link

Hi ,
would be great to have a data "authentik_prompt_fields"
at i don't know how to get UUID of existing prompt field

another suggestion would be great to modify existing stage with terraform, instead of creating quasi same stage , with only one difference.

john

@lyz-code
Copy link

lyz-code commented Feb 9, 2023

@DrummyFloyd if you open the network tab of your browser, when you edit a prompt stage you'll see a request to /api/v3/stages/prompt/prompts/ who's result gives you the data you need. I agree though that this is not a solution because you can't configure prompt stages without dealing with the web manually.

I'd love to have the data source too!

@lyz-code
Copy link

lyz-code commented Feb 9, 2023

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
}

@DrummyFloyd
Copy link
Author

thank you for your help , 'ive managed to do something similar ^^

will try to contribute asap

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants