DEV Community

Cover image for Implementing Spring Security 6 with Spring Boot 3: A Guide to OAuth and JWT with Nimbus for Authentication

Implementing Spring Security 6 with Spring Boot 3: A Guide to OAuth and JWT with Nimbus for Authentication

isaac uchechukwu on October 12, 2023

Introduction Since the introduction of Spring Security 6, I have encountered many developers who experienced issues getting their heads ...
Collapse
 
darkmoon profile image
gontran

Hello, thank you for this tutorial. When I try to retrieve the name of the authenticated user ( SecurityContextHolder.getContext().getAuthentication().getName() ) I get Null what should I do to solve this problem?

Collapse
 
osamamoinchawla profile image
osamamoinchawla

you getting NULL, there could be many possibilities:

  • there is no NAME field in user model
  • maybe the field is empty no value
  • check out for the spelling
Collapse
 
osamamoinchawla profile image
osamamoinchawla

hello gontran, have you be able to generate public and private RSA keys successfully?

Collapse
 
osamamoinchawla profile image
osamamoinchawla

Fantastic guide!
I am kinda stuck at RSA public and private key generation!!!
The commands you have written up are not working for me! is there any other way?

Collapse
 
vittorfraga profile image
Carlos Fraga

*in his github code there's a little difference:
*

private-key: classpath:certs/private-keyy.pem
  public-key: classpath:certs/public-key.pem
Enter fullscreen mode Exit fullscreen mode

*maybe thats why the command is not working, you can try replace the command
*

openssl pkcs8 -topk8 -inform PEM -outform PEM -in private-key.pem -out private-key.pem -nocrypt
Enter fullscreen mode Exit fullscreen mode

for

openssl pkcs8 -topk8 -inform PEM -outform PEM -in private-key.pem -out private-keyy.pem -nocrypt
Enter fullscreen mode Exit fullscreen mode
Collapse
 
osamamoinchawla profile image
osamamoinchawla

ERROR: "User account is locked"