Coder Social home page Coder Social logo

Principal about spring-addons HOT 3 CLOSED

ch4mpy avatar ch4mpy commented on June 3, 2024
Principal

from spring-addons.

Comments (3)

arnonuem avatar arnonuem commented on June 3, 2024 1

Ok i just found the solution to this. This repo could need some more documentation :D
In my case instead of using:

mockAuthentication(UsernamePasswordAuthenticationToken::class.java)

i had to just modify it to

val details = AppUserJwtAuthConverter.AppUserData("[email protected]", "fn", "Full", "Name")
mockAuthentication(UsernamePasswordAuthenticationToken::class.java).details(details)

And now the converter is also respected :)
Thanks a lot for that great repo. And please update your documentation in regards to the builder pattern with some more examples ;)

from spring-addons.

ch4mpy avatar ch4mpy commented on June 3, 2024

Did you have a look at @WithMockAuthentication javadoc?

If the actual Authentication impl type is of no importance (because you're only doing role-based security for instance), something like @WithMockAuthentication(name = "Ch4mpy", authorities = { "ROLE_TESTER", "ROLE_AUTHOR" }) should be just enough.

For UsernamePasswordAuthenticationToken, isn't Spring's @WithMockUser more convenient to use ?

I'm not sure I understood your use-case: UsernamePasswordAuthenticationToken really is bad Authentication impl when parsing a JWT. I'd suggest you to use Spring's JwtAuthenticationToken, Keycloak's KeycloakAuthenticationToken, my OidcIdAuthenticationToken or an implementation of your own better targeted at your specific OAuth2 impl (not so complicated actually)

from spring-addons.

arnonuem avatar arnonuem commented on June 3, 2024

from spring-addons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.