Deny User Access to Application if User is on IPV6

Problem statement

This article is addressing to those who wish to disable/ filter IPV6 from IPV4. By default, it is not possible to disable only with a custom Action.

Solution

A custom Action can be used to filter or disable IPV6. The code snippet below disables access with an IPV6:

const ipChecker = require('ip')

exports.onExecutePostLogin = async (event, api) => {

  const ip = event.request.ip;

  ipChecker.isV4Format(ip) ? console.log('V4')

  : api.access.deny(`Access to ${event.user.name} not allowed`)

  //Custom logic

};