zmstone ca87f0a43e feat: add 'is_empty_val' and 'not' functions to variform 1 年之前
..
include 6ac1ab7954 feat: Add clientinfo authn 1 年之前
src 65f7f98538 fix: ensure peerhost is string format for cinfo auth 1 年之前
test ca87f0a43e feat: add 'is_empty_val' and 'not' functions to variform 1 年之前
BSL.txt 6ac1ab7954 feat: Add clientinfo authn 1 年之前
README.md ca87f0a43e feat: add 'is_empty_val' and 'not' functions to variform 1 年之前
mix.exs a83127fabf ci(new mix build): add missing compile dependency 1 年之前
rebar.config 6ac1ab7954 feat: Add clientinfo authn 1 年之前

README.md

Authenticate clients with connection information

This application implements an extended authentication for EMQX Enterprise edition.

Client-info (of type cinfo) authentication is a lightweight authentication mechanism which checks client properties and attributes against user defined rules. The rules make use of the Variform expression to define match conditions, and the authentication result when match is found. For example, to quickly fencing off clients without a username, the match condition can be is_empty_val(username) associated with a attributes result deny.

The new authenticator config look is like below.

authentication = [
  {
    mechanism = cinfo
    checks = [
      # allow clients with username starts with 'super-'
      {
        is_match = "regex_match(username, '^super-.+$')"
        result = allow
      },
      # deny clients with empty username and client ID starts with 'v1-'
      {
        # when is_match is an array, it yields 'true' if all individual checks yield 'true'
        is_match = ["is_empty_val(username)", "str_eq(nth(1,tokens(clientid,'-')), 'v1')"]
        result = deny
      }
      # if all checks are exhausted without an 'allow' or a 'deny' result, continue to the next authentication
    ]
  },
  # ... more authentications ...
  # ...
  # if all authenticators are exhausted without an 'allow' or a 'deny' result, the client is not rejected
]

More match expression examples:

  • TLS certificate common name is the same as username: str_eq(cert_common_name, username)
  • Password is the sha1 hash of environment variable EMQXVAR_SECRET concatenated to client ID: str_eq(password, hash(sha1, concat([clientid, getenv('SECRET')])))
  • Client attributes client_attrs.group is not 'g0': str_neq(client_attrs.group, 'g0')
  • Client ID starts with zone name: regex_match(clientid, concat(['^', zone, '.+$']))

Contributing

Please see our contributing.md.

License

EMQ Business Source License 1.1, refer to LICENSE.