# Enhanced Auth Flow

VerneMQ supports [enhanced authentication](http://docs.oasis-open.org/mqtt/mqtt/v5.0/cs02/mqtt-v5.0-cs02.html#_Toc514345528) flows or SASL style authentication for MQTT 5.0 sessions. The enhanced authentication mechanism can be used for initial authentication when the client connects or to re-authenticate clients at a later point.

![](/files/3V5lWBoMGF2WSRVdIPnr)

The `on_auth_m5` hook allows the plugin to implement SASL style authentication flows by either accepting, rejecting (disconnecting the client) or continue the flow. The `on_auth_m5` hook is specified in the Erlang behaviour [on\_auth\_m5\_hook](https://github.com/vernemq/vernemq_dev/blob/master/src/on_auth_m5_hook.erl) in the [vernemq\_dev](https://github.com/vernemq/vernemq_dev) repo.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vernemq.com/plugin-development/enhancedauthflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
