Announcement Announcement Module
Collapse
No announcement yet.
Defining authorities-by-username-query doesn't work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Defining authorities-by-username-query doesn't work

    Hi All,

    I have tried to use the jdbc-user-service out of box but with some customization. It seems that defining the authorities-by-username-query doesn't work at all.

    Code:
       <authentication-manager>
            <authentication-provider>
                <password-encoder hash="md5"/>
                <!--<user-service id="userDetailsService"/>-->
                <jdbc-user-service data-source-ref="dataSource"
                                   authorities-by-username-query="select EMAIL as username, PASSWORD as password, 'true' as enabled from USER where EMAIL=?"
                        />
            </authentication-provider>
        </authentication-manager>
    Logs:

    Code:
    22:40:37,300 DEBUG SQLErrorCodeSQLExceptionTranslator:399 - Translating SQLException with SQL state '42S22', error code '1054', message [Unknown column 'username' in 'field list']; SQL was [select username,password,enabled from users where username = ?] for task [PreparedStatementCallback]
    It's still trying to execute the predefined SQL query.

    Does anyone know how to fix this issue?

    Thanks,
    Karim

  • #2
    The configuration you posted does not customize the way the users are queried. It customizes obtain the authorities (i.e. roles) for the user. You will want to use the users-by-username-query to customize how users are queried (you will also need to specify the authorities-by-username-query).

    Comment


    • #3
      That was the reason. I am not to sure, how is it possible that I haven't seen it

      Thanks again

      Comment

      Working...
      X