{
  "category": "user_based",
  "name": "Concurrent-Session-Management",
  "title": "Concurrent Session Management Template",
  "summary": "Prompts session handling to the users who belongs to any of the given set of roles based on currently active session count.",
  "preRequisites": [
    "Change the rolesList parameter to an array of roles of which users need to prompt for session handling.",
    "Modify the maxSessionCount parameter as required."
  ],
  "parametersDescription": {
    "rolesToStepUp": "An array of roles of which users should be prompted for session handling.",
    "maxSessionCount": "Maximum number of allowed concurrent sessions for the role which a particular user belongs to."
  },
  "defaultStepsDescription": {
    "Step 1": "Basic (Password) authenticator.",
  },
  "authenticationSteps":1,
  "defaultAuthenticators": {
    "1": {
      "local": [
        "BasicAuthenticator"
      ],
      "federated": []
    }
  },
  "helpLink": "https://docs.wso2.com/display/IS570/Configuring+Role-Based+Adaptive+Authentication",
  "code": [
    "// This script will prompt concurrent session handling",
    "// to one of the given roles",
    "// If the user has any of the below roles, concurrent session handling will be prompted",
    "// and it will either kill sessions or abort login based on number of active concurrent user sessions",
    "var rolesToStepUp = ['admin', 'manager'];",
    "var maxSessionCount = 1;",
    "",
    "function onLoginRequest(context) {",
    "   executeStep(1, {",
    "       onSuccess: function (context) {",
    "       // Extracting authenticated subject from the first step",
    "           var user = context.currentKnownSubject;",
    "           // Checking if the user is assigned to one of the given roles",
    "           var hasRole = hasAnyOfTheRoles(user, rolesToStepUp);",
    "",
    "           if (hasRole) {",
    "               Log.info(user.username + ' Has one of Roles: ' + rolesToStepUp.toString());",
    "               ensureMaxSessionCountNotExceededForUser(user, maxSessionCount);",
    "           }",
    "       }",
    "   });",
    "}"
  ]
}

Add template script for Concurrent Session Management
Add template script for Concurrent Session Management
