Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added authentication support for AQMP broker url #8057

Merged
merged 15 commits into from
Sep 20, 2021
2 changes: 2 additions & 0 deletions changelog/8057.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Added authentication support for connecting to external rabbitMQ server.
nakshathru marked this conversation as resolved.
Show resolved Hide resolved
Currently user has to pass a username and password hardcoded url inorder to connect to external rabbitMQ.
nakshathru marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 4 additions & 1 deletion rasa/core/brokers/pika.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from asyncio import AbstractEventLoop
from collections import deque
from typing import Deque, Dict, Optional, Text, Union, Any, List, Tuple
from urllib.parse import urlparse

import aio_pika

Expand Down Expand Up @@ -168,7 +169,9 @@ async def _connect(self) -> aio_pika.RobustConnection:
# The `url` parameter will take precedence over parameters like `login` or
# `password`.
if self.host.startswith("amqp"):
url = self.host

parsed_host = urlparse(self.host)
url = f"{parsed_host.scheme}://{self.username}:{self.password}@{parsed_host.netloc}:{self.port}"

ssl_options = _create_rabbitmq_ssl_options(self.host)
logger.info("Connecting to RabbitMQ ...")
Expand Down