goauthentik / terraform-provider-authentik

Manage https://goauthentik.io with terraform.
https://registry.terraform.io/providers/goauthentik/authentik/latest/docs
GNU General Public License v3.0
59 stars 16 forks source link

Add resource and data source for OAuth Scope Mapping #446

Closed ar3s3ru closed 6 months ago

ar3s3ru commented 6 months ago

It appears there is no resource nor data source that we could use to provide or access an OAuth Scope Mapping.

It would be nice to have one.

Perhaps authentik_property_mapping_oauth or authentik_property_mapping_oauth_scope to keep it consistent with the existing naming?

rissson commented 6 months ago

Hi, you can use existing resources to achieve this:

data "authentik_scope_mapping" "scope-email" {
  managed = "goauthentik.io/providers/oauth2/scope-email"
}

resource "authentik_scope_mapping" "scope-user-pk" {
  name        = "OAuth mapping: OpenID 'user_pk'"
  scope_name  = "user_pk"
  description = "User ID"
  expression  = <<EOF
return {
  "id": request.user.pk,
}
EOF
}