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

OAuth 2.0 fails with MySQL and maria-db-java-client-2.4.1.jar #1092

Open
kdrkrst opened this issue Apr 27, 2019 · 0 comments
Open

OAuth 2.0 fails with MySQL and maria-db-java-client-2.4.1.jar #1092

kdrkrst opened this issue Apr 27, 2019 · 0 comments

Comments

@kdrkrst
Copy link

kdrkrst commented Apr 27, 2019

Description:
WSO2 IS 5.7.25 raises following error with MySQL 5.7 database and maria-db-java-client.jar:
org.wso2.carbon.identity.oauth2.IdentityOAuth2Exception: Error occurred while trying to retrieve latest 'ACTIVE' access token for Client ID : awUI98s3ZZkn10bfW_VFcgu7eXga, User ID : ******, and Scope : read at org.wso2.carbon.identity.oauth2.dao.AccessTokenDAOImpl.getLatestAccessToken(AccessTokenDAOImpl.java:473)
...
Caused by: java.sql.SQLException: Every derived table must have its own alias at org.mariadb.jdbc.internal.protocol.AbstractQueryProtocol.readErrorPacket(AbstractQueryProtocol.java:1594)

Full stacktrace is added.
full-trace.txt

While configuring the secondary user store I have faced the 'SSLException Unsupported record version Unknown-0.0' issue with mysql JDBC driver (see https://stackoverflow.com/questions/48947926/jdbc-to-mysql-5-7-21-with-java-1-8-0-162-unsupported-record-version-unknown-0). Changed my driver jar to maria-db-java-client-2.4.1.jar as suggested. As stated here MariaDB Connector/J is developed for use with MariaDB and MySQL database servers. Version compatibility seems satisfied.

Enabled the SQL trace logs for mariadb and investigated the issue, and found out that the something amiss with the query executed at line: 395

Here is the query causing the error:
SELECT * FROM (SELECT ACCESS_TOKEN, REFRESH_TOKEN, TIME_CREATED, REFRESH_TOKEN_TIME_CREATED, VALIDITY_PERIOD, REFRESH_TOKEN_VALIDITY_PERIOD,TOKEN_STATE, USER_TYPE, TOKEN_ID, SUBJECT_IDENTIFIER FROM IDN_OAUTH2_ACCESS_TOKEN WHERE CONSUMER_KEY_ID=(SELECT ID FROM IDN_OAUTH_CONSUMER_APPS WHERE CONSUMER_KEY = 'awUI98s3ZZkn10bfW_VFcgu7eXga') AND LOWER(AUTHZ_USER)='mahitaptokpinar' AND TENANT_ID=-1234 AND USER_DOMAIN='BOYKOT-USERSTORE' AND TOKEN_SCOPE_HASH='ecae13117d6f0584c25a9da6c8f8415e' AND TOKEN_STATE='ACTIVE' ORDER BY TIME_CREATED DESC) WHERE ROWNUM < 2

Regarding to the MySQL query syntax, the inner SELECT statement has to have a table alias ('T' or 'T1', etc..).

As digging out, I guess the code hits the 'else' statement at line 363 failing to detect the actual JDBC driver name. Thus, query targets Oracle, instead of MySQL as actual JDBC driver name returns: MariaDB Connector/J

Affected Product Version:
WSO2 IS 5.7.25

OS, DB, other environment details and versions:
OS: CentOS 7.6
DB: MySQL 5.7

Steps to reproduce:

  1. Configure IDENTITY_DB to use MySQL 5.7 and add maria-db-java-client-2.4.1.jar to <PRODUCT_HOME>/repository/components/lib folder.
  2. Follow steps in: https://www.youtube.com/watch?v=xipHJSW93KI
  3. curl -v -X POST --basic -u $CLIENTID:$CLIENTSECRET -H "Content-Type: application/x-www-form-urlencoded;charset=UTF-8" -k -d "grant_type=password&username=$USERNAME&password=$PASSWORD&scope=$SCOPE" $TOKEN_EP
shilmyhasan pushed a commit to shilmyhasan/identity-inbound-auth-oauth-1 that referenced this issue Dec 20, 2023
…tps_support-6.4.2.x-full

Change repo URLs to https in pom.xml files of support-6.4.2.x-full
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant