Anope IRC Services

Please login or register.

Login with username, password and session length
Advanced search  


Pages: [1]   Go Down

Author Topic: [m_sql_authentication] '"Registered" users  (Read 3201 times)

0 Members and 1 Guest are viewing this topic.


  • Anope User
  • Offline Offline
  • Posts: 4
[m_sql_authentication] '"Registered" users
« on: January 22, 2014, 08:54:56 PM »


First of all, I want to thank the developers of Anope for their work on Anope. I've been using it for almost a decade now, and I've started to become familiar with some of 2.0.0's MySQL features. This is the first time in all that time I've ever had the need to register on the boards and ask for help about a feature as I've always strived to resolve any problem I've had myself.

I'm currently running 2.0.0-rc1 on Unreal (latest stable) (I know rc2 is now available, but with full time work I won't have until the weekend to upgrade). I'm using the following modules:

- m_mysql
- m_http
- m_webcpanel
- m_xmlrpc & m_xmlrpc_main
- enc_sha256
- db_flatfile
- db_sql (not db_sql_live)

I've enabled m_sql_authentication as I built my own account management system in PHP/MySQL running on NGINX. The account system works fine.

The way I have this set up is for users to auth to the site using a username that is only used on the site. Once they register and log in, they are then given the opportunity to register a nick. This checks for it already existing, then if not, it adds it to the users ircnick column in MySQL. In Anope, I use the following query:

Code: [Select]
SELECT 'eml' FROM (the db).(the table) WHERE 'ircnick' = @a@ AND 'sha2hash' = SHA2(CONCAT('sha2salt', @p@), 0)
And here's where the problem I'm having starts:

The nick I had used to test (which is also in anope.db), despite the password being right was being rejected. I registered a test account on the site which wasn't in anope.db, and it now tells me the nick isn't registered. The logs for the event (with services running in debug mode) are as follows (with my host changed):

Code: [Select]
[Jan 22 20:29:22.395018 2014] Debug: m_sql_authentication: Checking authentication for CardareTest
[Jan 22 20:29:22.396031 2014] Debug: m_sql_authentication: Unsuccessful authentication for CardareTest
[Jan 22 20:29:22.396176 2014] COMMAND: CardareTest! used IDENTIFY and failed to identify to nonexistent account CardareTest
[Jan 22 20:29:22.396352 2014] Debug: Sent: :NickServ NOTICE CardareTest :Nick CardareTest isn't registered.

In the DB, there is a user with the 'ircnick' of "CardareTest", so it should be returning at least one row, unless the SQL is wrong? I tried running it on the mysql commandline, and it spat out an SHA256 hash that didn't match the one in the DB, so I'm wondering if Services is presenting the password given in IRC not in SHA256, but in another format? One of the other recent threads suggested that passwords might be being passed to the DB in base64 encoded format, but he was using enc_none (I'm using enc_sha256).

Any thoughts as to what I might be doing wrong here?

I do appreciate any help given, and I hope I've included enough information.


  • Team
  • *
  • Offline Offline
  • Posts: 463
Re: [m_sql_authentication] '"Registered" users
« Reply #1 on: January 22, 2014, 09:38:25 PM »

The password given in the query (as @p@) is in plain text and is the same password given to /ns identify.


  • Anope User
  • Offline Offline
  • Posts: 4
Re: [m_sql_authentication] '"Registered" users
« Reply #2 on: January 22, 2014, 10:45:25 PM »

That'd explain why it wasn't working, so cheers for that!

I've managed to get it working perfectly now. Altered the query as follows (just in case anyone else finds this thread trying to do the same as me):

Code: [Select]
SELECT eml AS 'email' FROM (db).(table) WHERE ircnick = @a@ AND sha2hash = SHA2(CONCAT(sha2salt, SHA2(@p@,0)), 0)
Change (db) and (table) to your respective database name and table name containing your accounts.

Cheers again. :)
Pages: [1]   Go Up