Font Size:

Web Filter Plugin

Introduction

A plugin that act as a web filter, and to intercept the HTTP request and do some pre-processing & post-processing to the response.

Commons Use Cases:

  • Setting Response Headers

  • URL Redirection

  • Content Encryption

  • Custom Authentication

Web Filter Plugin Classes

Interface

  • org.joget.plugin.base.PluginWebFilter

    • Its extends the javax.servlet.Filter & org.joget.plugin.base.ActivationAwarePlugin

    • Exactly same implementation as a Filter

    • Execute based on provide URL Patterns

    • URL Patterns are following AntPathMatcher syntax which is wisely used in Spring Framework.

Abstract

  • org.joget.apps.app.model.PluginWebFilterAbstract

    • Extended ExtDefaultPlugin and implemented PluginWebFilter

Auto register/unregister the filter using PluginWebFilterUtil

Interface

  • org.joget.plugin.base.PluginWebFilter

    • Its extends the javax.servlet.Filter

    • Exactly same implementation as a Filter

    • Execute based on provide URL Patterns

    • URL Patterns are following AntPathMatcher syntax which is wisely used in Spring Framework.

Abstract

  • org.joget.apps.app.model.PluginWebFilterAbstract

    • Extended ExtDefaultPlugin & 

Auto register/unregister the filter using PluginWebFilterUtil

org.joget.plugin.base.PluginWebFilter

Methods

  • String getName()

    • Method returning the name of the filter

  • String[] getUrlPatterns()

    • Method returning a URL patterns array to apply the filter.

    • The url pattern using AntPathMatcher syntax

  • boolean isPositionAfterSecurityFilter()

    • A flag to make the filter execute after security chain. If after, you can get the logged in user.

  • int getOrder()

    • The order of plugin web filter execution

  • void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

    • The filter logic implementation

org.joget.apps.app.model.PluginWebFilterAbstract

Methods

  • void afterRegister()

    • Auto calling PluginWebFilterUtil.registerFilter to register the filter when installed.

  • void beforeUnregister()

    • Auto calling PluginWebFilterUtil.unregisterFilter to unregister the filter when uninstalling.

  • boolean isPositionAfterSecurityFilter()

    • Default to return true.

  • int getOrder()

    • Default to return 0.

Sample Plugins

  • SampleHeaderFilter

    • Add header to the response of /web/login

    • Run before security chain and order after SampleLoginFormEncryption even it register before it.

  • SampleWebFilterPlugin

    • Intercept /web/login request and auto login as Admin when the saved URL is assignment link. Then, it direct to the configured redirect url or home.

  • SampleLoginFormEncryption

    • Intercept the /web/login to inject script to encrypt the login credentials before body end tag

    • Intercept /j_spring_security_check to decrypt the credentials before passing to security chain.

    • Run before security chain

  • SampleJwtLoginFilter

    • Intercept all URLs  with /** to authenticate with JWT token

    • Run before security chain

Created by Debanraj Last modified by Debanraj on Apr 17, 2025