Mysql-proxy read_query method implements post-Authentication connection after executing special SQL statements

Source: Internet
Author: User

The mysql-proxy read_query method implements authentication connection after special SQL is executed. In mysql-proxy, you can set session variables, this function allows you to perform Secondary authentication by executing the specified SQL statement after obtaining the database connection. If no secondary authentication is performed, all requests connected to the database are intercepted and an error is returned. Java code local authed = false function read_query (packet) if (authed = false) then if packet: byte () = proxy. COM_QUERY then if (packet: sub (2): lower () = "select 2013 from dual") then authed = true else proxy. response. type = proxy. MYSQLD_PACKET_ERR proxy. response. errmsg = "unauthed connection !!! "Return proxy. PROXY_SEND_RESULT end else proxy. response. type = proxy. MYSQLD_PACKET_ERR proxy. response. errmsg =" unauthed connection !!! "Return proxy. PROXY_SEND_RESULT end

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.