Code Monkey home page Code Monkey logo

uidmonitor's Introduction

PAN-OS UserID transaction monitor

Palo Alto Networks NGFW's feature a very powerfull API endpoint called User-ID.

It allows tagging IP address objects as well as User objects. These tags can then be used to dynamically group IP addresses (Dynamic Address Group - DAG) as well as to dynamically group users (Dynamic User Group - DUG). Resulting groups can be consumed in several policies like session security or packet forwarding.

The User-ID API allows, as well, registering these user objects (User Login/Logout) and these IP address objects (Object Register/Unregister)

One of the most powerful details of the corresponding PAN-OS feature is both registration and tag transactions can contain a timeout value. This way the user can, for instance, register a user login with a 10 minute expiration mark and then leave the NGFW take care of removing the entry at its due time.

There are tons of examples on how to script the User-ID API so these groups could be created from SNMP alerts, SYSLOG events or application log messages.

As the use case grows (in number to objects and tags) the need for a easy way to query the current state (of group membership) raises in urgency. Although PAN-OS provides CLI, WebUI and XML API ways of displaying the current state I always missed a basic tag-to-ip API endpoint that could dump the corresponding list in plain text format.

This small "man-in-the-midle" proxy application monitors User-ID API payloads and keeps its own copy of registered objects and tags. It tracks due date of the objects and tags using its own internal clock reference (unsynchonised from the NGFW).

Then it exposes the basic dump endpoint in GET /edl/?list=[user|group|tag]&key=<tag>

Running the application

There is only one mandatory TARGET environmental variable configuration value to be provided in the form of host:port (FQDN or Address of the PAN-OS device to proxy)

TARGET="<ip:port>" go run .

A http service would be started in the port 8080 of localhost. The http service will forward all messages to the NGFW (including the User-ID API ones). But it will monitor User-ID transactions keeping its internal state alive.

Use the http://127.0.0.1:8080/edl/?list=[user|group|tag]&key=<tag> URL to dump the state of the different lists.

The application would honour a different TCP port as provided in the PORT environmental variable. In case the NGFW device is using a self-signed or untrusted certificate then you can configure the proxy to ignore the certificate chain with INSECURE=true

TARGET="<ip:port>" PORT=8081 INSECURE=true go run .

Microservice version

A Dockerfile is provided to pack the code in a distroless container.

Or you can use the prebuild docker image

docker pull ghcr.io/xhoms/uidmonitor:latest

uidmonitor's People

Contributors

xhoms avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.