# Authentication & Authorization via external HTTP server If clients accessing the broker are managed by another application, it can implement API endpoints that respond with information about client authentication and/or topic-level authorization. - `amqtt.contrib.http.UserAuthHttpPlugin` (client authentication) - `amqtt.contrib.http.TopicAuthHttpPlugin` (topic authorization) Configuration of these plugins is identical (except for the uri name) so that they can be used independently, if desired. # User Auth See the [Request and Response Modes](#request-response-modes) section below for details on `params_mode` and `response_mode`. !!! info "browser-based mqtt over websockets" One of the primary use cases for this plugin is to enable browser-based applications to communicate with mqtt over websockets. !!! warning Care must be taken to make sure the mqtt password is secure (encrypted). For more implementation information: ??? info "recipe for authentication" Provide the client id and username when webpage is initially rendered or passed to the mqtt initialization from stored cookies. If application is secure, the user's password will already be stored as a hashed value and, therefore, cannot be used in this context to authenticate a client. Instead, the application should create its own encrypted key (eg jwt) which the server can then verify when the broker contacts the application. ??? example "mqtt in javascript" Example initialization of mqtt in javascript: import mqtt from 'mqtt'; const url = 'https://path.to.amqtt.broker'; const options = { 'myclientid', connectTimeout: 30000, username: 'myclientid', password: '' // encrypted password }; try { const clientMqtt = await mqtt.connect(url, options); ::: amqtt.contrib.http.UserAuthHttpPlugin.Config options: show_source: false heading_level: 4 extra: class_style: "simple" # Topic ACL See the [Request and Response Modes](#request-response-modes) section below for details on `params_mode` and `response_mode`. ::: amqtt.contrib.http.TopicAuthHttpPlugin.Config options: show_source: false heading_level: 4 extra: class_style: "simple" [//]: # (manually creating the heading so it doesn't show in the sidebar ToC) [](){#request-response-modes}