-
cli
Official Command Line Interface for the IPinfo API (IP geolocation and other types of IP data) (by ipinfo)
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
Learn more about Permit or IPInfo — or access the whole code repository for this project here.
import { Permit } from "permitio"; const permit = new Permit({ pdp: "http://localhost:7766", // your API Key token: process.env.PERMIT_API_KEY, }); const fetchLocationByIP = async () => { const request = await fetch( `https://ipinfo.io/json?token=${process.env.IP_INFO_TOKEN}` ); const jsonResponse = await request.json(); console.log(jsonResponse.ip, jsonResponse.country); return jsonResponse.country; }; export default async function enforceAccess(req, res) { // Getting the country code and storing in a variable const IPlocation = await fetchLocationByIP(); const allowed = await permit.check( { key: "[email protected]", attributes: { // Passing the variable to the ip_location attribute ip_location: IPlocation, }, }, "view", { type: "only-uk", tenant: "default", } ); res.status(200).send({ allowed }); return allowed; }
If you would like to check out a guide on how to add a user to Permit after successful authentication with Auth0, check out the article here.