Results 1 to 3 of 3

Thread: Defining authorities-by-username-query doesn't work

  1. #1
    Join Date
    Jan 2011
    Posts
    5

    Default 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. #2
    Join Date
    Jan 2008
    Posts
    1,826

    Default

    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).
    Rob Winch - @rob_winch
    Spring Security Lead
    Pivotal

  3. #3
    Join Date
    Jan 2011
    Posts
    5

    Default

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

    Thanks again

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •