New Plugin Contribution: Geo/IP-Based Auth Rules #1255

Closed
opened 2026-03-13 08:30:11 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @0xPratikPatil on GitHub (May 23, 2025).

📦 Plugin Name

better-auth-geoip


Description

I’m working on a new community plugin for better-auth that introduces Geo/IP-Based Authentication Rules. This plugin aims to provide an extra layer of security by enabling developers to allow or block login attempts based on IP geolocation, risk scoring, and anonymity signals (VPN, TOR, proxy).


🔐 Features

  • Support for IP geolocation providers:

    • ipapi.co
    • ipinfo.io
    • IPQualityScore
  • Block or allow based on:

    • Country codes
    • VPN/proxy/TOR detection
    • ASN (future support)
    • IP reputation/risk score
  • Configurable via plugin options

  • Designed for plug-and-play usage


🔧 Example Usage

import { betterAuth } from "better-auth";
import { geoIpPlugin } from "better-auth-geoip";

export const auth = betterAuth({
  advanced: {
    ipAddress: {
      ipAddressHeaders: ["x-client-ip", "x-forwarded-for"],
      disableIpTracking: false,
    },
  },
  plugins: [
    geoIpPlugin({
      provider: "ipqualityscore",
      apiKey: process.env.IPQS_API_KEY!,
      config: {
        blockCountries: ["CN", "RU"],
        maxRiskScore: 70,
        blockIfVPN: true,
        blockIfTor: true,
      },
    }),
  ],
});

🙋‍♂️ Request

I’d love to contribute this as an official community plugin and would appreciate feedback on:

  • This does not conflict with the upcoming Better Auth Infrastructure features, so I can proceed with working on it directly.
  • Whether to open a PR or keep it as an external module
  • Adding it to the docs/community plugin registry
Originally created by @0xPratikPatil on GitHub (May 23, 2025). ### 📦 Plugin Name `better-auth-geoip` --- ### ✨ Description I’m working on a new **community plugin** for `better-auth` that introduces **Geo/IP-Based Authentication Rules**. This plugin aims to provide an extra layer of security by enabling developers to allow or block login attempts based on IP geolocation, risk scoring, and anonymity signals (VPN, TOR, proxy). --- ### 🔐 Features * Support for IP geolocation providers: * `ipapi.co` * `ipinfo.io` * `IPQualityScore` * Block or allow based on: * Country codes * VPN/proxy/TOR detection * ASN (future support) * IP reputation/risk score * Configurable via plugin options * Designed for plug-and-play usage --- ### 🔧 Example Usage ```ts import { betterAuth } from "better-auth"; import { geoIpPlugin } from "better-auth-geoip"; export const auth = betterAuth({ advanced: { ipAddress: { ipAddressHeaders: ["x-client-ip", "x-forwarded-for"], disableIpTracking: false, }, }, plugins: [ geoIpPlugin({ provider: "ipqualityscore", apiKey: process.env.IPQS_API_KEY!, config: { blockCountries: ["CN", "RU"], maxRiskScore: 70, blockIfVPN: true, blockIfTor: true, }, }), ], }); ``` ### 🙋‍♂️ Request I’d love to contribute this as an **official community plugin** and would appreciate feedback on: * **This does not conflict with the upcoming Better Auth Infrastructure features, so I can proceed with working on it directly.** * Whether to open a PR or keep it as an external module * Adding it to the docs/community plugin registry
Author
Owner

@carlosmfreitas2409 commented on GitHub (May 29, 2025):

This is a really great idea!
One suggestion is to also support .mmddb files.

@carlosmfreitas2409 commented on GitHub (May 29, 2025): This is a really great idea! One suggestion is to also support `.mmddb` files.
Author
Owner

@dosubot[bot] commented on GitHub (Aug 28, 2025):

Hi, @0xPratikPatil. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You proposed the better-auth-geoip community plugin for Geo/IP-based authentication enhancements.
  • The plugin includes VPN/TOR detection and risk scoring features.
  • You asked about compatibility with upcoming features and whether to submit a PR or keep it external.
  • The maintainer showed interest and suggested support for .mmddb files.
  • The discussion is ongoing regarding security improvements and integration options.

Next Steps:

  • Please let me know if this issue is still relevant with the latest version of better-auth by commenting here.
  • If I don’t hear back within 7 days, I will automatically close this issue.

Thanks for your understanding and contribution!

@dosubot[bot] commented on GitHub (Aug 28, 2025): Hi, @0xPratikPatil. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You proposed the better-auth-geoip community plugin for Geo/IP-based authentication enhancements. - The plugin includes VPN/TOR detection and risk scoring features. - You asked about compatibility with upcoming features and whether to submit a PR or keep it external. - The maintainer showed interest and suggested support for .mmddb files. - The discussion is ongoing regarding security improvements and integration options. **Next Steps:** - Please let me know if this issue is still relevant with the latest version of better-auth by commenting here. - If I don’t hear back within 7 days, I will automatically close this issue. Thanks for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1255