WSO2 APIM server doesn't start after changing default DB to MySQL - wso2

I followed the WSO2 documentation (https://apim.docs.wso2.com/en/latest/install-and-setup/setup/setting-up-databases/changing-default-databases/changing-to-mysql/) to change the default DB to MySQL.
I executed the below steps:
Created 2 databases named wso2am_db and wso2shared_db using MySQL 8.0 client.
Ran the scripts to create the required tables in both the DB's.
Created a user named wso2carbon and granted access on both the DB's.
Verified that the DB's, tables and users are created successfully.
Made the required configuration changes in deployment.toml file as shown below.
[database.apim_db]
type = "mysql"
driver="com.mysql.cj.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/wso2am_db"
username = "wso2carbon"
password = "wso2carbon"
[database.shared_db]
type = "mysql"
driver="com.mysql.cj.jdbc.Driver"
url = "jdbc:mysql://localhost:3306/wso2shared_db"
username = "wso2carbon"
password = "wso2carbon"
But on restarting the WSO2 APIM server, I am getting the below error in terminal and the server doesn't start.
It gets stuck after this message and nothing comes up after this. Am i going wrong somewhere? Need help with this.

This might be happening due to mutual SSL connection failure when connecting to the SQL server. Can you try out this again with the following configuration in deployment.toml file.
[database.apim_db]
type = "mysql"
url = "jdbc:mysql://localhost:3306/wso2am_db?useSSL=false"
username = "wso2carbon"
password = "wso2carbon"
[database.shared_db]
type = "mysql"
url = "jdbc:mysql://localhost:3306/wso2shared_db?useSSL=false"
username = "wso2carbon"
password = "wso2carbon"

Related

AWS SES sending email from Django App fails

I am trying to send mail with using SES and already setup the mail configuration. Now SES running on production mode -not sandbox-. But in Django App, when I try to send mail nothing happens. it's only keep trying to send, no error.
in setting.py made the configuration.
INSTALLED_APPS = [
'django_ses',
]
EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_ACCESS_KEY_ID = config('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = config('AWS_SECRET_ACCESS_KEY')
AWS_SES_REGION_NAME = 'ap-northeast-1'
AWS_SES_REGION_ENDPOINT = 'email-smtp.ap-northeast-1.amazonaws.com'
and email method.
def send_mail(request, user, emails, subject, path):
current_site = get_current_site(request)
message = render_to_string(f"store/emails/{path}.html", {
"some": "context"
})
send_email = EmailMessage(subject, message, "info#mydomain.com", to=emails)
send_email.send()
By the way I already verified the info#mydomain.com in SES console. And when I try to send email from the SES console using send test email option, I can send without a problem. But in Django App. I can't.
Is there any other settings should I do. Because I can't see any error popping when I try to send mail. It's only keep trying to send. But it can't.
AWS SES provides two types of endpoints: API and SMTP
You are using SMTP one
AWS_SES_REGION_ENDPOINT = 'email-smtp.ap-northeast-1.amazonaws.com'
But 'django_ses.SESBackend' working with API type.
Try to set:
EMAIL_BACKEND = 'django_ses.SESBackend'
AWS_SES_REGION_ENDPOINT = 'email.ap-northeast-1.amazonaws.com'
If you want to use usual SMTP connection, you probably need to swap current backend with backends.smtp.EmailBackend and set SMTP connection parameters.

Update Default Curl command in Dev portal of WSO2

in wso2 3.0 on dev portal -> go-to application -> generate keys -> click generate curl for token
it shows the above image with localhost how do I change it with the domain of my dev portal or how do i update it to some other value
You can change it to the host name of the Gateway by updating the https_endpoint value under [[apim.gateway.environment]] in the deployment.toml. In this case the host name of the token url will be updated to the host name of the Gateway you define. For more info, check here.
Otherwise, if you have separate key-manager configurations, you can update the service_url value under [apim.key_manager] config in the deployment.toml. For more info, check here. In this case, the host name of the token url will be the host name of the key-manager service
For APIM v320, you can use the following configurations.
[[apim.gateway.environment]]
name = "Production and Sandbox"
type = "hybrid"
display_in_api_console = true
description = "This is a hybrid gateway that handles both production and sandbox token traffic."
show_as_token_endpoint_url = true
service_url = "https://localhost:${mgt.transport.https.port}/services/"
username= "${admin.username}"
password= "${admin.password}"
ws_endpoint = "ws://localhost:9099"
wss_endpoint = "wss://localhost:8099"
http_endpoint = "http://gw:${http.nio.port}"
https_endpoint = "https://gw:${https.nio.port}"
The following configs are used.
show_as_token_endpoint_url
https_endpoint
The endpoint is derived from the https endpoint and it appends the token context.

Why am I facing flask-mail issues?

I am not sure what should I do
from flask import Flask
from flask_mail import Mail, Message
app = Flask(__name__)
with app.app_context():
app.config['MAIL_SERVER'] = 'smtp.gmail.com'
app.config['MAIL_PORT'] = 587
app.config['MAIL_DEFAULT_SENDER'] = 'sender'
app.config['MAIL_USERNAME'] = 'sender'
app.config['MAIL_PASSWORD'] = '*************'
app.config['MAIL_USE_TSL'] = True
mail = Mail(app)
mail.send_message('Mail sent', sender = 'sender', recipients = ['recipients'], body = 'Mail sent successfully')
It tells me
smtplib.SMTPNotSupportedError: SMTP AUTH extension not supported by server I've even enabled emails from less secure apps in gmail. Why does it not seem to work?
I've tried looking the error up and haven't found much of a satisfactory answer yet.
Edit: I used SSL instead of TLS for the encryption and it seems to show me a different error. Now it tells me smtplib.SMTPSenderRefused: (530, b'5.7.0 Authentication Required. Learn more at\n5.7.0 https://support.google.com/mail/?p=WantAuthError I have no idea what to do next. I don't know how to enable DisplayUnlockCaptcha. https://accounts.google.com/DisplayUnlockCaptcha is the link for it. I proceeded with what the link said, it told "Account access enabled
Please try signing in to your Google Account again from your new device or application." and I retried, still fail to sign in.
Issue has been fixed!
There are several ways you can try, such as activating ssl
app.config['MAIL_PORT'] = 465
app.config['MAIL_USE_TLS'] = False
app.config['MAIL_USE_SSL'] = True
You must not enable both tls and ssl together
You need to apply a series of settings to your Gmail account, such as disabling 2FA or Display Unlock Captcha, etc.
The steps of the work are outlined in this tutorial.
https://twilio.com/blog/2018/03/send-email-programmatically-with-gmail-python-and-flask.html

Can't connect to MongoDB via flask_pymongo

I just encountered a problem while playing with Flask and MongoDB. Here are scenarios
With Authorization Enabled
If I use PyMongo() from flask_pymongo with mongo = PyMongo(app) pattern, I just get Authorization Errors. While I am able to successfully retrieve database via MonogoClient() from pymongo using same connection string.
Without Authorization Enabled
If I use flask_pymongo, no errors. But I am not getting any data either. For example, mongo.db.collection_names() just returns empty array. With MongoClient(), the same operation was successful.
I am using:
python = 3.6.3
flask = 0.12.2
flask_pymongo = 0.5.1
pymongo = 3.5.1
Thanks in Advance
I've been using Flask with Flask-PyMongo for a while now, and below is how I make my connections to a mongodb.
from flask import Flask
from flask_cors import CORS
from flask_pymongo import PyMongo
app = Flask(__name__)
CORS(app) # very important!
USERNAME = '<username>'
PASSWORD = '<password>'
PORT = '27017'
HOST = 'localhost'
app.config['MONGO_DBNAME'] = '<DB Name>'
app.config['MONGO_HOST'] = HOST
app.config['MONGO_PORT'] = PORT
app.config['MONGO_USERNAME'] = USERNAME
app.config['MONGO_PASSWORD'] = PASSWORD
mongo = PyMongo(app)
You may not need the CORS(app) depending on your setup.
To create multiple connections do the following:
# Users db
app.config['MONGO2_DBNAME'] = 'users'
app.config['MONGO2_HOST'] = HOST
app.config['MONGO2_PORT'] = PORT
app.config['MONGO2_USERNAME'] = USERNAME
app.config['MONGO2_PASSWORD'] = PASSWORD
users_mongo = PyMongo(app, config_prefix='MONGO2')
I should also note that I had problems connecting with authorization through Flask-PyMongo because the database needed to have authorization configured a certain way. Flask-PyMongo expects the db authority to be on the database itself and not elsewhere. So when creating a user and password for a db do the following inside a mongo shell:
Create user admin
use admin
db.createUser({user: "userAdmin", pwd: "", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } )
Create user on YOUR db
use <YOUR db>
db.createUser({user: "", pwd: "", roles:[{ role: "dbAdmin", db: ""}, {role: "readWrite", db: ""}]})
Within mongo and even with PyMongo you can create users within one database and give them access to other dbs, but Flask-PyMongo for whatever reason does not play nice here and you'll need the user created within the database you want to use.
Hope this helps as I've struggled here as well. Feel free to ask for clarification

unable to send emails django-helpdesk

I am using django-helpdesk for ticketing system.
its working fine but i am not able to send emails. i am testing this on my localhost.
while i submit a ticket, its getting submitted properly but submitter is not getting any email for newly created ticket.
i added new queue and provided details like E-Mail Address, E-Mail Box Type, E-Mail Hostname, E-Mail Port, Use SSL for E-Mail=False, E-Mail Username, E-Mail Password, IMAP Folder, E-Mail Check Interval properly.
but emails not getting sent.
then i removed all off above from queue and added settings like
QUEUE_EMAIL_BOX_TYPE = IMAP
QUEUE_EMAIL_BOX_SSL = True
QUEUE_EMAIL_BOX_HOST = 'smtp.gmail.com'
QUEUE_EMAIL_BOX_USER = 'email'
QUEUE_EMAIL_BOX_PASSWORD = 'pwd'
but still its not working.
am i missing any settings? please help me out.
QUEUE_EMAIL_BOX settings are not for sending emails, but for receiving them. Configuration for sending emails goes into standard email settings from django.
If you're using SMTP backend (this is default), configuration should be:
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'email'
EMAIL_HOST_PASSWORD = 'pwd'
EMAIL_USE_SSL = True