Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring security - Mysql - problem

 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
I am having problem with change ROLE_ prefix. I have BD mysql with some function like: Manager, Vendor etc. So, i would like to use on my


this way:



how can i do it?

anyone could i help me, please?

this my code:


thanks!
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have bad news. You can't

For some reason your Roles in Spring Security must be prefixed with "ROLE_"

I figured this out tearing my hair out for hours a year ago.

So in your query to load the data just prepend the "ROLE_"

like

SELECT username, 'ROLE_' || real_role_field FROM myRoleTable where username = ?

Mark
 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

ohh my god, bad news. I spent my all day with this and i did not find any solution. i do not get understand why required we have ROLE_ like prefix, legacy app does not record on BD ROLE_ADMIN.

Now i have this code:



So, if i use your sugesst i will get to fix?




thanks for your help...
 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark,

I got to fix, look:
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool, I didn't know about the concat function in MySql, the sql I wrote works in Oracle, so assumed it would work elsewhere.

Congrats on getting it to work.

Mark
 
camilo lopes
Ranch Hand
Posts: 202
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mark,

Yes, looks good with concat function. I have not tested in other BD. but it seems to work ok.

thanks for your help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic