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

Authentication Flow / Subflow / Executions priorities #973

Open
Writtscher opened this issue Jun 10, 2024 · 1 comment
Open

Authentication Flow / Subflow / Executions priorities #973

Writtscher opened this issue Jun 10, 2024 · 1 comment

Comments

@Writtscher
Copy link

Hi. I am trying to create a custom authentication flow. This is my terraform file:

resource "keycloak_authentication_flow" "vpp_authentication_flow" {
  realm_id = keycloak_realm.vpp.id
  alias    = "vpp browser"
}

resource "keycloak_authentication_bindings" "vpp_vpp_authentication_flow_authentication_binding" {
  realm_id     = keycloak_realm.vpp.id
  browser_flow = keycloak_authentication_flow.vpp_authentication_flow.alias
}

resource "keycloak_authentication_execution" "vpp_authentication_flow_cookie_authentication_execution" {
  realm_id          = keycloak_realm.vpp.id
  parent_flow_alias = keycloak_authentication_flow.vpp_authentication_flow.alias
  authenticator     = "auth-cookie"
  requirement       = "ALTERNATIVE"
  depends_on = []
}

resource "keycloak_authentication_execution" "vpp_authentication_flow_identity_provider_redirector_authentication_execution" {
  realm_id          = keycloak_realm.vpp.id
  parent_flow_alias = keycloak_authentication_flow.vpp_authentication_flow.alias
  authenticator     = "identity-provider-redirector"
  requirement       = "ALTERNATIVE"
  depends_on = [
    keycloak_authentication_execution.vpp_authentication_flow_cookie_authentication_execution
  ]
}

resource "keycloak_authentication_subflow" "vpp_browser_authentication_subflow" {
  realm_id          = keycloak_realm.vpp.id
  parent_flow_alias = keycloak_authentication_flow.vpp_authentication_flow.alias
  alias             = "browser forms"
  requirement       = "ALTERNATIVE"
  depends_on = [
    keycloak_authentication_execution.vpp_authentication_flow_identity_provider_redirector_authentication_execution
  ]
}

resource "keycloak_authentication_execution" "vpp_authentication_flow_username_password_form_authentication_execution" {
  realm_id          = keycloak_realm.vpp.id
  parent_flow_alias = keycloak_authentication_subflow.vpp_browser_authentication_subflow.alias
  authenticator     = "auth-username-password-form"
  requirement       = "REQUIRED"
}

resource "keycloak_authentication_execution" "vpp_authentication_flow_session_counter_authentication_execution" {
  realm_id          = keycloak_realm.vpp.id
  parent_flow_alias = keycloak_authentication_subflow.vpp_browser_authentication_subflow.alias
  authenticator     = "user-session-limits"
  requirement       = "REQUIRED"
  depends_on = [
    keycloak_authentication_execution.vpp_authentication_flow_username_password_form_authentication_execution
  ]
}

resource "keycloak_authentication_execution_config" "vpp_authentication_flow_session_counter_authentication_execution_config" {
  realm_id     = keycloak_realm.vpp.id
  execution_id = keycloak_authentication_execution.vpp_authentication_flow_session_counter_authentication_execution.id
  alias        = "vpp browser authentication flow session counter config"
  config = {
    "behavior"        = "Deny new sessions",
    "errorMessage"    = "You are already logged in. Please close the other session.,
    "userClientLimit" = "1",
    "userRealmLimit"  = "0",
  }
}

It works but the priority of the executions is wrong

The result of this is:

{
    "id": "0d7ca48f-7601-4c09-ba4d-79c1b38303d1",
    "alias": "vpp browser",
    "description": "",
    "providerId": "basic-flow",
    "topLevel": true,
    "builtIn": false,
    "authenticationExecutions": [
      {
        "authenticatorFlow": true,
        "requirement": "ALTERNATIVE",
        "priority": 1,
        "autheticatorFlow": true,
        "flowAlias": "browser forms",
        "userSetupAllowed": false
      },
      {
        "authenticator": "auth-cookie",
        "authenticatorFlow": false,
        "requirement": "ALTERNATIVE",
        "priority": 2,
        "autheticatorFlow": false,
        "userSetupAllowed": false
      },
      {
        "authenticator": "identity-provider-redirector",
        "authenticatorFlow": false,
        "requirement": "ALTERNATIVE",
        "priority": 2,
        "autheticatorFlow": false,
        "userSetupAllowed": false
      }
    ]
  }

The priority should be auth-cookie -> identity-provider-redirector -> forms subflow. I tried everything (depends_on). but no luck. What am I missing?

@ofairfoul
Copy link

ofairfoul commented Jul 23, 2024

Keycloak 25 introduced a new priority field on authenticationExecution and this provider has not implemented them yet

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