Spring Security using Spring Data JPA + MySQL + Spring Boot | Java Techie

Ғылым және технология

This video explain you how to implement spring security for Authentication and authorization from Database and how to encrypt and decrypt password
#JavaTechie #SpringBoot #SpringSecurity
GitHub:
github.com/Java-Techie-jt/spr...
Blogs:
javagyanmantra.wixsite.com/we...
Facebook page:
/ 919464521471923
Like and subscribe

Пікірлер: 289

  • @niharrjpattanayak4406
    @niharrjpattanayak44064 жыл бұрын

    finally, I clearly understood all those stuff. I tried to watch and read many videos and blogs but they are just defining all the methods and attributes without saying its workflow. but u just cleared my doubt. Thanks once again

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Glad to hear this Nihar

  • @leawitkiewicz
    @leawitkiewicz4 жыл бұрын

    Very good work, I have watched a lot of spring channels but yours is one of the bests. :3 this rain sounds at the end is satysfying and chilling omg

  • @Javatechie
    @Javatechie5 жыл бұрын

    Hi Guys , as i can see few of comments that it is not working as expected so let me know if you want me to repeat this tutorial once again ? no worries feel free to raise your doubts any time .

  • @adepuvijayalaxmi1521

    @adepuvijayalaxmi1521

    4 жыл бұрын

    Hello java techie Iam getting unexpected < error in postman while hitting post request method. After setting basic authentication of admin. Can you help me how to resolve?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Do you have TeamViewer installed in your system ? So that I can check this out remotely

  • @sawankumarpanigrahi9949

    @sawankumarpanigrahi9949

    4 жыл бұрын

    i am facing this issue org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: Can't configure antMatchers after anyRequest

  • @vikaspooner9846

    @vikaspooner9846

    4 жыл бұрын

    yes sir do repeat it

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    @@vikaspooner9846 ok I will do that

  • @kabira__shaikh
    @kabira__shaikh6 жыл бұрын

    Really appreciable work Basanta :) Thanks for this one.

  • @Aguuuu91
    @Aguuuu913 жыл бұрын

    This video is awesome! Thank you so much for explaining this topic so well, it finally made it all so much clearer to me. :)

  • @ikhbayar1000
    @ikhbayar10004 жыл бұрын

    This is best tape, I ever seen before about Spring boot application.

  • @wf3644
    @wf36443 жыл бұрын

    This is the only video which shows how to do it with the database entities in an industry format. nice work man, I'm currently learning Spring this is a helpful video

  • @theritesh973
    @theritesh9736 жыл бұрын

    Great work , Thank you soo much for posting such a valuable video.

  • @maheshwaghmare2312
    @maheshwaghmare23125 жыл бұрын

    Thank you sir very nice explanation and demonstration

  • @sonamkumari-jj7yj
    @sonamkumari-jj7yj4 жыл бұрын

    Very nice video on spring security.....Thanks!

  • @akashpisal3582
    @akashpisal35822 жыл бұрын

    Thanks for quick tutorial and to the point.

  • @benvinertt2150
    @benvinertt21503 жыл бұрын

    man you awesome , i watch alot of videos and you very understood, thank you!!

  • @umamaheswarreddy9204
    @umamaheswarreddy92044 жыл бұрын

    OMG ! you solved my problem.Thank you so much

  • @sumantmishra3207
    @sumantmishra3207 Жыл бұрын

    Thank you for sharing so much knowledge with us

  • @keymalerock
    @keymalerock4 жыл бұрын

    thanks bro. you really help mankind

  • @krishnavidala7296
    @krishnavidala72965 жыл бұрын

    very nice one......and thanks Basant

  • @asamhemanthkumar
    @asamhemanthkumar3 жыл бұрын

    Very informative tutorial 👍👍👍👍

  • @dakshsaini8274
    @dakshsaini82743 жыл бұрын

    Thanks man for this great tutorial

  • @oumaimakabouri3491
    @oumaimakabouri34915 жыл бұрын

    Many thanks for this video.

  • @przemysawkaleta4053
    @przemysawkaleta40534 жыл бұрын

    thanks a lot, very good tutorial, , for me the best with entities cooperated with database

  • @vinodnayak27
    @vinodnayak27 Жыл бұрын

    Great I really love the way you explain concepts with deep coding. I need your explanation with diagrams.. actually it is difficult to remembers every ponit you mention. With diagrams I can map earily or recollect easity

  • @hippiestafarii
    @hippiestafarii5 жыл бұрын

    Hi. Many thanks for this tutorial ; very well explained :-) Cheers :-)

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Glad to hear from you sir

  • @ashwinkumar504
    @ashwinkumar5044 жыл бұрын

    Good one Thanks for the post

  • @user-rh7fg5gn4b
    @user-rh7fg5gn4b5 жыл бұрын

    awesome tutorial dear man

  • @aniketaglawe8585
    @aniketaglawe85853 жыл бұрын

    KEEP IT UP ..LOVE IT

  • @gauravk002
    @gauravk0022 жыл бұрын

    You are a exceptional person..

  • @Javatechie

    @Javatechie

    2 жыл бұрын

    Thanks buddy

  • @srinathn1600
    @srinathn16006 жыл бұрын

    Good work

  • @mc1aify
    @mc1aify4 жыл бұрын

    Thanks ...could you more elaborate the userdetails and userdetailService....

  • @brice3002
    @brice30023 жыл бұрын

    man you are the best! thanks for this vid :)

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Hi Dorsey , this is video is more clear please have a look remake version kzread.info/dash/bejne/haR2qsaQprWxips.html

  • @brice3002

    @brice3002

    3 жыл бұрын

    @@Javatechie Thanks. i have followed the steps, but i can not add a new user using '/secure/rest/admin/add/'. Although i have 2 Admin stored in the DB. I have create a new endpoint that do not need Authentication and then use them to add new admin in the DB.

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Cool , you are not able to add because you need to exclude that perticular URL from antMatchers I would strongly suggest you to checkout my second video which link I mentioned above that will really help you

  • @kingkhan-jp9zv
    @kingkhan-jp9zv2 жыл бұрын

    this is the best ..please make videos in hindi

  • @nagireddy1507
    @nagireddy15075 жыл бұрын

    thanks alot bro....

  • @jyotsanarai6715
    @jyotsanarai6715 Жыл бұрын

    Good video , just one suggestion , I have seen you write many things without explaining about them as If you are talking to yourself , ex - EnableGlobalMethodSecurity etc . Please don't take it negative way , just a small suggestion to make your future videos more elaborate .

  • @karthikm7875
    @karthikm78754 жыл бұрын

    HI , im facing issue with "Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: Can't configure antMatchers after anyRequest" unable to solve this,plz can you help on this error....

  • @techtips7641

    @techtips7641

    4 жыл бұрын

    Hi Karthik, Could u try with the below one and check once, http.authorizeRequests() .antMatchers("/rest/**").permitAll().and().authorizeRequests().antMatchers("/secure/**").hasAnyRole("ADMIN").anyRequest().authenticated().and().formLogin().permitAll(); This combination can be used only one -->.anyRequest().authenticated() we are using multiple times. Kindly change

  • @basitali9651
    @basitali96513 жыл бұрын

    Greate work basant,pls make a video on angular auth guards and rout guards to authenticate this service

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Okay Basit I will try

  • @gourishankarmohanty3927
    @gourishankarmohanty39275 жыл бұрын

    Awesome Explanation Basant. . Please Make Video on Oauth2. Thanks In Advance.

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Sure will do it soon.

  • @JavaLovers

    @JavaLovers

    5 жыл бұрын

    @@Javatechie Any date tentatively when we can see OAUTH 2

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Am not sure about date , few more concept is pending for upload once I will done this then will try to upload Oauth2

  • @arkaimps
    @arkaimps4 жыл бұрын

    great video.... Learnt a lot from this one. A quick question regarding the last segment, when U were trying to Post new User with basant credentials , Postman threw error, but response code was 200. Were we expecting 200 or 403?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    To achieve proper status code we need to specify that in controller

  • @arkaimps

    @arkaimps

    4 жыл бұрын

    @@Javatechie Thanks for your suggestion. I tried to work as per your tutorial but it seems UserDetailsServices are never being called and hence always throwing Forbidden error irrespective of Admin or User. Can you please suggest, what can be the root cause? github.com/arkajnag/JPA-MySQL

  • @helletuxen3751
    @helletuxen37515 жыл бұрын

    nice love it

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Thank u so much sir

  • @naveenparmar5328
    @naveenparmar53282 жыл бұрын

    Hi @Java Techie While testing with Postman to add a user to the database, There is no "user added successfully" message at the end also there is no user added. And there is no error showing in the console as well sir can u plz help me its not working while i am trying to hit the end point on postman and on web browser as well.

  • @gautamsnegi27
    @gautamsnegi274 жыл бұрын

    Any specific reason to disable csrf token? Is it just we will be browser dependent to generate the csrf token and since we are not hitting the APIs via browser we are disabling it?

  • @vikaspooner9846
    @vikaspooner98464 жыл бұрын

    i am getting login form for every request except for "/" in postman ?? Help me.

  • @TheSunRise-PS
    @TheSunRise-PS Жыл бұрын

    Good :)

  • @kumarmanish9046
    @kumarmanish90464 жыл бұрын

    35:58 what is the use of .formLogin() method ?

  • @omkarpalekar4237
    @omkarpalekar42373 жыл бұрын

    Hi, I have below query. please assist. Thanks "I Have checked your code an unable to figure out, how you have set userDetails object to user object in "CustomUserDetailsService" class . Since there is no such "setUser"method defined in "CustomUserDetails" class."

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Please checkout this kzread.info/dash/bejne/haR2qsaQprWxips.html

  • @tareque540
    @tareque540 Жыл бұрын

    Great video! I have a question though why did you create a table solely for roles couldn't you have just added a role attribute to each user ?

  • @Javatechie

    @Javatechie

    Жыл бұрын

    Yes but it is a good practice to keep a separate entity

  • @AhmedMkhinini
    @AhmedMkhinini6 жыл бұрын

    thks. But How to make a cal for my rest services from my client using the users credentials ?

  • @Javatechie

    @Javatechie

    6 жыл бұрын

    Ahmed you need to pass user credential as part of request header

  • @shad7764
    @shad77644 жыл бұрын

    Hello, I am getting a HTTP 403 when trying to add new user after adding url authorization rules. I have configured it the same as you mentioned in the video

  • @RanjithKumar-qj9mn

    @RanjithKumar-qj9mn

    4 жыл бұрын

    Please let me know if you are through with it "Adding new user" share the code in git hub

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    If you follow steps initially without implement security I added new user . please do the same

  • @RanjithKumar-qj9mn

    @RanjithKumar-qj9mn

    4 жыл бұрын

    I can Add users with out security. but with security and roles enabled not working for me. Only link Authentication works

  • @sujithg5873
    @sujithg58734 жыл бұрын

    Bro how can we change this login through rest?now we called userdetsils from security class that changed to rest.its possible?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Didn't get you , this is what we are doing in rest api only

  • @dp-sg8hc
    @dp-sg8hc3 жыл бұрын

    Hi, Authentication works fine but role based authentication doesn't work even for basic methods. It is redirecting me back to the login page as html file in postman, I have cloned your code only. When i test post operation (localhost:8080/secure/rest/admin/add) in postman, i am getting the below error even though i have provided admin username and password . I am not understanding why I am getting the 200 http status code like you but not the user successfully added Error response: Please sign in

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Please checkout my latest spring security video . I explained things from scratch again That helps you

  • @kundanprasad8951
    @kundanprasad89514 жыл бұрын

    Hi Basant I followed you spring security with JPA video, but I have a problem with Spring security,occasionally throwing Bad Credentials even i am providing the correct credentials I did several project builds and deployments (on Tomcat 9), without changing anything in the code. Furthermore, when the error is thrown in login page(bad credentials) I have no errors in the console. is this a bug of some sort? How can I solve it? Thank you!

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Can you add a debugger and check whether request is going to your user details service or not

  • @amansheikh1801
    @amansheikh18012 жыл бұрын

    thanks

  • @vikaspooner9846
    @vikaspooner98464 жыл бұрын

    I am getting this error: failed to lazily initialize a collection of role: com.fetch.entity.User.roles, could not initialize proxy - no Session

  • @user-ps9tf3xz9v

    @user-ps9tf3xz9v

    4 жыл бұрын

    add to your application.properties file the following line: spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true

  • @madhumitanaskar962
    @madhumitanaskar9623 жыл бұрын

    Hi thanks for sharing the video. but I have a question- that at the end (video timing 43:04) the status is not showing forbidden even the role of "Basant" is "user". there might be some code issue I guess

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Yes please checkout my latest spring security video

  • @zhrgci
    @zhrgci2 жыл бұрын

    How is it supposed to check d? When I debug it never hits CustomUserDetailsService

  • @alisacrowe6063
    @alisacrowe60634 жыл бұрын

    Thank you for course, but it is not able to autowire the userDetailsService in the SecurityConfig file. I took it directly from GitHub. I says that there is more than one bean.

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Did you check out my code ?

  • @alisacrowe6063

    @alisacrowe6063

    4 жыл бұрын

    @@Javatechie yes, i downloaded it from github - same problem

  • @alisacrowe6063

    @alisacrowe6063

    4 жыл бұрын

    Are you having the same problem that I am having?

  • @alisacrowe6063

    @alisacrowe6063

    4 жыл бұрын

    @@Javatechie yes, i downloaded it from github - same problem. Are you having the same problem as me?

  • @kumarmanish9046
    @kumarmanish90464 жыл бұрын

    14:00 what is the use of disabling csrf ?

  • @gangadharkodi5568
    @gangadharkodi55683 жыл бұрын

    Sir, I am using STS but i am not able to write below two line in appication.properties page can you help me what is the problem "Spring.jpa.properties.hibernate.dialect" and "Hibernate.formate_sql"

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Why what is the problem any error ?

  • @rakeshyadav7079
    @rakeshyadav70794 жыл бұрын

    when try to add the user it shows login page html only do not says added successfully

  • @rudranarayandash1466
    @rudranarayandash14664 жыл бұрын

    do we need DaoAuthenticationProvider ?

  • @silviupopa2895
    @silviupopa28953 жыл бұрын

    How the .set(user) method from MyUserDetails is working? I get it with red (error), it doesn't exist! The method is used in loadUserByUsername in CustomUserDetailsService. Please help !!

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    This is inbuilt method given by spring security to set user object in Userdetails

  • @silviupopa2895

    @silviupopa2895

    3 жыл бұрын

    @@Javatechie I type the method but it doesn't work. There is another one with the same problem. Thanks for The response!

  • @kallamrajareddy
    @kallamrajareddy6 жыл бұрын

    thanks basant can u make an example on the same base with adding OAuth2

  • @Javatechie

    @Javatechie

    6 жыл бұрын

    Kallam sure will do it soon

  • @kallamrajareddy

    @kallamrajareddy

    6 жыл бұрын

    thanks

  • @79EasyE
    @79EasyE3 жыл бұрын

    Hi java techie this tutorial is good but it seems the way you write your filter chain is outdated or maybe I am missing something but I get an error of type "Can't configure antMatchers after anyRequest" when I use you filterchain. I've been reading up and this kind of syntax doesn't seem right.

  • @zahidgul2008

    @zahidgul2008

    Жыл бұрын

    Yeah, Faced the same issue

  • @shubhamnavghare1937
    @shubhamnavghare19373 жыл бұрын

    why do we use service layer in spring boot? is it necessary for every spring boot project?

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Yes it's necessary

  • @gauravverma5475
    @gauravverma54754 жыл бұрын

    when i am using this code::: http.authorizeRequests().antMatchers("/rest/**").authenticated().anyRequest().permitAll().and() .authorizeRequests().antMatchers("/secure/**").authenticated().anyRequest().hasAnyRole("ADMIN").and() .formLogin().permitAll(); show this exception : :: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: Can't configure antMatchers after anyRequest. and not showing any service path in console. please solve the problem.

  • @AmandeepSingh-sx9ke
    @AmandeepSingh-sx9ke5 жыл бұрын

    Hey can anyone tell me how to provide white space for multiple lines ? What is the shortcut ?

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Use regular expression and replaceAll

  • @maheshwaghmare2312
    @maheshwaghmare23125 жыл бұрын

    can you add the video for securing rest api using token generation in spring boot

  • @RohitShindes
    @RohitShindes4 жыл бұрын

    I am unable to find setUser() method in customUserDetailService in method loadByUsername. Can plz you explain me grantedAuthority functionality used in customUserDetails? Can you plz help?

  • @silviupopa2895

    @silviupopa2895

    3 жыл бұрын

    I have the same problem ! I tried some other tutorials and replace that method, but I am not sure if it's good. Did you solve that?

  • @gauravkumardwivedi2290
    @gauravkumardwivedi22904 жыл бұрын

    Relation b/w User and Role wil be OneToMany or ManyToMany I am confused ? or we can go with anyone.

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    One to many

  • @yacc8339

    @yacc8339

    3 жыл бұрын

    @@Javatechie Can you explain why or give any resource on why this is? In my understanding there should be many to many as one user can have many roles and one role can be added to many users. Please reply.

  • @shreyanshrathi6051
    @shreyanshrathi60515 жыл бұрын

    Sir, My Url Based Authentication is running but the role based is not running it's Showing that UserDetailsService cannot be Autowired. How do i solve this problem ?

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Please follow step by step how I explained if required refer Github source code

  • @mehdiqanbarzade4530

    @mehdiqanbarzade4530

    5 жыл бұрын

    how you resolve this problem?

  • @mehdiqanbarzade4530

    @mehdiqanbarzade4530

    5 жыл бұрын

    @@Javatechie i do it! but doesn't work? but for both the users ADMIN and USER, it doesn't allow

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Did u used proper antmatchers ? if there is small change in syntax then it won't work

  • @rameshbabu5754
    @rameshbabu57544 жыл бұрын

    could you please explain the hi-level flow for the above same application with diagram.

  • @vinodnayak27

    @vinodnayak27

    Жыл бұрын

    Great I really love the way you explain concepts with deep coding. I need your explanation with diagrams.. actually it is difficult to remembers every ponit you mention. With diagrams I can map earily or recollect easity

  • @Javatechie

    @Javatechie

    Жыл бұрын

    Vinod can you check my spring security internal flow video

  • @AskirAskanon
    @AskirAskanon4 жыл бұрын

    this is just saving my ass so much in our grp project we have to do in school, ty so much sir! :D just one question, what is the programm or probably plugin, called that u use for your REST API request such as post, delete etc etc?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    I added postman plugin extension in chrome browser , even you can install it in your desktop

  • @AskirAskanon

    @AskirAskanon

    4 жыл бұрын

    @@Javatechie ty very much, for your quick anwser!

  • @AskirAskanon

    @AskirAskanon

    4 жыл бұрын

    for some reason when i try to do a request, i get as response basically the login page instead of "user added sucessfully" like in ur example :/ even tho i pass in the admin in the "basic auth" part in the postman.. weird

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    @@AskirAskanon I would suggest you to import my code then run it . If it works then compare

  • @AskirAskanon

    @AskirAskanon

    4 жыл бұрын

    @@Javatechie i used ur github project, and it doesnt work either, so the problem is on my side , guess im using postman wrong probably, but nevertheless ty very much sir for your help!!

  • @msrao8884
    @msrao88844 жыл бұрын

    When i login through postman the above example it is giving error "status": 404, "error": "Not Found", "message": "No message available", "path": "/"

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Check URL mapping

  • @aayushkc2306
    @aayushkc23064 жыл бұрын

    plz make the full playlist on thymeleaf

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Thymeleaf just a template engine so it's easy to design your template same like HTML , Please do mention your requirement so that I can try it .

  • @aayushkc2306

    @aayushkc2306

    4 жыл бұрын

    @@Javatechie all the nessary thing i am having trouble with the documentation and i didnt find the nessary tutorail on thymeleaf..... plz help me

  • @adnan93khan
    @adnan93khan4 жыл бұрын

    I am not able to mapped RequestMappingHandlerMapping

  • @jaysurya1190
    @jaysurya11902 ай бұрын

    Hello JavaTechie i want to say that the class you are extending in SecurityConfig is deprecated and no class import WebSecurityAdapter how can solve this is there any other way to to do kindly create a new video for that

  • @pankajsharma-rf1ov
    @pankajsharma-rf1ov3 жыл бұрын

    when I tried to insert data using security then m getting problem

  • @basitali9651

    @basitali9651

    3 жыл бұрын

    @PreAuthorize("hasAnyRole('ADMIN')") uncomment it

  • @JavaLovers
    @JavaLovers5 жыл бұрын

    @Java Techie I am running this same program I am able to successfully add ADMIN and USER but thereafter security configuration enabled I am trying to add USER through ADMIN which is in DB again through this URL localhost:8080/secure/rest/admin/add but on postman it opens an HTML form which asks user and password but what I am expecting that it would add the user, please advise what is wrong

  • @varunmathur4609

    @varunmathur4609

    5 жыл бұрын

    I am getting the same issue

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Hi if it is asking again login page just check once are you able to see query log in console or not . If not something wrong configuration in user details service . Try this else do let me know

  • @obeyobey3838

    @obeyobey3838

    4 жыл бұрын

    I do have query log in console but still the same problem. Otherwise, thank you so much for all tutoriels . I am really enjoying it.

  • @jawehers

    @jawehers

    3 жыл бұрын

    @@Javatechie am getting the same thing an html with login form .. any help please?

  • @hemagogawale6988
    @hemagogawale6988 Жыл бұрын

    even i do the same code in postman i cant add user even as authorize with my ADMIN User it give me HTML error how to solve it please help me

  • @Javatechie

    @Javatechie

    Жыл бұрын

    Please check out this kzread.info/dash/bejne/haR2qsaQprWxips.html

  • @mohankadam1070
    @mohankadam1070 Жыл бұрын

    I am trying to extend Security config to WebSecurityConfigrurerAdapter but not ale to do it any suggestion

  • @Javatechie

    @Javatechie

    Жыл бұрын

    Please check out the session below 👇 kzread.info/dash/bejne/Z5541KR9ZLyXfaw.html

  • @mohankadam1070

    @mohankadam1070

    Жыл бұрын

    @@Javatechie WebSecurityConfigrurerAdapter is now depreciated, refer spring documents

  • @pragyanshreedas23594
    @pragyanshreedas235943 жыл бұрын

    can this API be used in android for login applications?????

  • @tienta8053
    @tienta80534 жыл бұрын

    hello. In Spring new version, SecurityConfig.class throw exception: Can't configure antMatchers after anyRequest, can you solve it?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Hi we can configure , which version you are using?

  • @tienta8053

    @tienta8053

    4 жыл бұрын

    @@Javatechie first, thank you for reply and then this is Spring boot 2.x. Can you show me how to solve it?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    @@tienta8053 spring boot 2.x internally use spring 5 , So can you check my first spring security video , you can find I used antmatchers

  • @tienta8053

    @tienta8053

    4 жыл бұрын

    I did just as you tutorial even copied the code on GitHub but when running the program still throws the error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'springSecurityFilterChain' defined in class path resource [org/springframework/security/config/annotation/web/configuration/WebSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.servlet.Filter]: Factory method 'springSecurityFilterChain' threw exception; nested exception is java.lang.IllegalStateException: Can't configure antMatchers after anyRequest

  • @tienta8053

    @tienta8053

    4 жыл бұрын

    @@Javatechie I think the problem lies in this code: http.authorizeRequests().antMatchers("/rest/**").authenticated().anyRequest().permitAll().and() .authorizeRequests().antMatchers("/secure/**").authenticated().anyRequest().hasAnyRole("ADMIN").and() .formLogin().permitAll();

  • @kallamrajareddy
    @kallamrajareddy6 жыл бұрын

    i tried this example but it works without hasAnyRole if we remove only it’s working otherwise 403 error

  • @Javatechie

    @Javatechie

    6 жыл бұрын

    Kallam behavior should be same if user role is not authorized then it should give 403 forbidden

  • @kallamrajareddy

    @kallamrajareddy

    6 жыл бұрын

    but i am using ADMIN role

  • @kallamrajareddy

    @kallamrajareddy

    6 жыл бұрын

    i am trying with ORACLE

  • @wallacebarbosa26

    @wallacebarbosa26

    6 жыл бұрын

    Yes, he forgot one thing. "role.getRole()" CustomUserDetails java class you need to fix ( SimpleGrantedAuthority("ROLE_" + role) ) to SimpleGrantedAuthority("ROLE_" + role.getRole()). now system ROLE will work fine and you can use hasAnyRole again.

  • @Javatechie

    @Javatechie

    6 жыл бұрын

    wallace please check in UserDetailsServive already mentioned

  • @sagarsaud156
    @sagarsaud1563 жыл бұрын

    How to implement auto login after sign up process?

  • @ajaydhami5631
    @ajaydhami56314 жыл бұрын

    I am getting this Error: " Can't configure antMatchers after anyRequest" Below is my configure method from SecurityCOnfig: @Override protected void configure(HttpSecurity http) throws Exception { http.csrf().disable(); http.authorizeRequests() .antMatchers("/rest/**").authenticated() .anyRequest().permitAll() .and() .authorizeRequests() .antMatchers("/secure/**").authenticated() .anyRequest().hasAnyRole("ADMIN") .and() .formLogin().permitAll(); }

  • @robertodelcampo5462

    @robertodelcampo5462

    4 жыл бұрын

    Me too, did you fixed it ?

  • @robertodelcampo5462

    @robertodelcampo5462

    4 жыл бұрын

    This sould works fine, you can delete non secured line if you dont need unsecured enpoints: @Override protected void configure(HttpSecurity http) throws Exception{ http.antMatcher("/**") .authorizeRequests() .antMatchers("/endpoint/not/notSecured", "endpoints/not/secureds/**").permitAll() .antMatchers("/admin/endpoints/**").hasAnyRole("ADMIN") .anyRequest().authenticated().and().formLogin().permitAll(); }

  • @lovebarua8277
    @lovebarua82775 жыл бұрын

    i get an a error even I send correct user name and password with correct role exception is : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL was not normalized.

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    It seems some firewall issue

  • @lovebarua8277

    @lovebarua8277

    5 жыл бұрын

    How can i fix this can uh suggest answer for this query

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Can we connect remotely so that I can access your code .

  • @apegedara6060
    @apegedara60604 жыл бұрын

    Hi , I followed your tutorial & staring to do it but I m getting error org.springframework.beans.factory.UnsatisfiedDependencyException: etc ... PLease help me

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Please share complete error

  • @shalumariamsheji
    @shalumariamsheji3 жыл бұрын

    can u share db schema used for this?

  • @3infob525
    @3infob5254 жыл бұрын

    why if i do like that http.authorizeRequests().antMatchers("/secure/**").authenticated().anyRequest().permitAll() or like this http. authorizeRequests().antMatchers("/r/**").authenticated().anyRequest().hasAnyRole("ADMIN").and() .formLogin().permitAll(); it works but both of them doesn't work !!!!!

  • @VINEETKUMAR-ps4yu
    @VINEETKUMAR-ps4yu3 жыл бұрын

    Sir in Security config page we find more than one bean can not autowire error during autowirng time in UserDetailsService ,I copy Your github config Security page code ,again we get same error ,i am using intelij ,and when i am using @Qualifire Annotaion then again find same error ,how can fix it.

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Few bugs is there in This perticular video because of spring boot version . I will remake this spring security role base authentication

  • @VINEETKUMAR-ps4yu

    @VINEETKUMAR-ps4yu

    3 жыл бұрын

    ​@@Javatechie​ http.authorizeRequests().antMatchers("/rest/**").permitAll().and().authorizeRequests().antMatchers("/secure/**").hasAnyRole("ADMIN").anyRequest().authenticated().and().formLogin().permitAll(); sir when using this code it executed successfully but when we check on postman then it does not add user after entering admin user and password

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    I need to check this again

  • @sushantshiwakoti5578
    @sushantshiwakoti55785 жыл бұрын

    Why is it throwing acess denied everytime, even though i am providing correct username and password, i cannot access any url because of this

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Could you check in your console , whether it hit the DB or not

  • @sushantshiwakoti5578

    @sushantshiwakoti5578

    5 жыл бұрын

    @@Javatechie yes it did and i get admin as username and password with role as ADMIN,

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Can you please share log with me or error stack javatechie4u@gmail.com

  • @surajpatil3452

    @surajpatil3452

    5 жыл бұрын

    same pinch, when i tried from postman. it was wirking fine from browser. what i did is i added http.httpBasic().and().authorizeRequests()..... and in CustomUserDetails.java - in getAuthorities() :- there should be role.getRole(). after this it allowed me gr8 job .

  • @shubhamnavghare1937
    @shubhamnavghare19373 жыл бұрын

    what does NoArgsConstructor do??

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    It will add no argument constructor in your class

  • @krishnaeditz3462
    @krishnaeditz34622 жыл бұрын

    have you added custom login page..?

  • @Javatechie

    @Javatechie

    2 жыл бұрын

    No

  • @gurjitkaur4201
    @gurjitkaur42015 жыл бұрын

    I am unable to add user with Admin and user roles for the first time without authentication. Please help its giving me "Full authentication is required to access this resource" error in postman

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    Did you provide valid credential ?

  • @gurjitkaur4201

    @gurjitkaur4201

    5 жыл бұрын

    @@Javatechie where do I need to provide creds? I am simply adding new user to database without authentication, like u did in first step added admin and user roles users, there only I am unable to save details to db

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    @@gurjitkaur4201 got it , When I added user that time I didn't enable spring security related stuff , So please do the same , remove spring security dependency, and configuration stuff then try once

  • @gurjitkaur4201

    @gurjitkaur4201

    5 жыл бұрын

    @@Javatechie yes Sir, am also doing the same I am just following every step as shown by you in this tutorial and adding user and admin without security. But I am unable to add so and getting 401 unauthorized access error

  • @Javatechie

    @Javatechie

    5 жыл бұрын

    @@gurjitkaur4201 could you please share your code via GitHub so that I can import and will try to help you out

  • @siddharthausekar9196
    @siddharthausekar91964 жыл бұрын

    Authentication works fine but role based authentication doesn't work even for basic methods. It is redirecting me back to the login page as html file in postman

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Can you import my code then compare it

  • @siddharthausekar9196

    @siddharthausekar9196

    4 жыл бұрын

    @@Javatechie it;s the same code. just changed the properiest file for sql connect

  • @siddharthausekar9196

    @siddharthausekar9196

    4 жыл бұрын

    properties*

  • @abijithgs3132
    @abijithgs31323 жыл бұрын

    Hi, @Java Techie, I am able to understand most of the things but in the end, there is an issue can u help me in resolving it. While testing with Postman to add a user to the database, There is no "user added successfully" message at the end also there is no user added.

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    Are you able to see DB query in console ?

  • @abijithgs3132

    @abijithgs3132

    3 жыл бұрын

    @@Javatechie Nope there is no response in the console. I get only a 200 OK success message with a HTML code

  • @Javatechie

    @Javatechie

    3 жыл бұрын

    It means your jpa not inject , check whether you annotate @Component in your UserDetailsService or not

  • @abijithgs3132

    @abijithgs3132

    3 жыл бұрын

    @@Javatechie I tried with that as well it is not working .ALso u haven't given @Component in ur code. Can I share the screenshots of the code through some platform? if u r comfortable

  • @naveenparmar5328

    @naveenparmar5328

    2 жыл бұрын

    i am also getting the same issue

  • @karthikm7875
    @karthikm78754 жыл бұрын

    hi, when im using above 2.2. version , facing issue on this security configuration. please give me proper solution . "con't configure antMacthers after anyRequest".......

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Please check my jwt example and copy paste configuration

  • @karthikm7875

    @karthikm7875

    4 жыл бұрын

    @@Javatechie in postman every time returning "document.f.username.focus(); " this html error. unable to find the solution for this error .please tell how can i solve and i want do POST operation in Postman

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    @@karthikm7875 as I mention loginform sonyou can't access it directly from postman Do one thing remove that configuration then try accessing it

  • @karthikm7875

    @karthikm7875

    4 жыл бұрын

    @@Javatechie sorry, i tried same way but im not fix this issue, now it showing 403 and im following same way what are the steps you mention in video. please give me any solution.

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Can share errors log in javatechie4u@gmail.com

  • @yashwanthreddygowreddigari1997
    @yashwanthreddygowreddigari1997Ай бұрын

    Why @ getter @ setter you can use @ data directly

  • @Javatechie

    @Javatechie

    Ай бұрын

    Yes we can.

  • @mansisd_world1115
    @mansisd_world11152 жыл бұрын

    Can you show this by taking studen details and then if user is admin then only show delete column and if the user is other then admin then just show edit column in the database table

  • @Javatechie

    @Javatechie

    2 жыл бұрын

    Check below video kzread.info/dash/bejne/haR2qsaQprWxips.html

  • @Javatechie

    @Javatechie

    2 жыл бұрын

    Part 2 kzread.info/dash/bejne/pnmWqracaKW1kbQ.html

  • @kevinnakandakare2300
    @kevinnakandakare23004 жыл бұрын

    how are you exactly checking if the password given in webpage matches the password in database?

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    If you notice I wrote one jpa query to fetch user based on email ? I consider email as unique identification .

  • @mumblepie5367

    @mumblepie5367

    4 жыл бұрын

    @@Javatechie Sorry if I'm wrong but i don't think you ever fetch based on email. Not in this project

  • @Javatechie

    @Javatechie

    4 жыл бұрын

    Sorry my mistake I used fundByUserName method in CustomUserDetailsService class

  • @susantkumar2889
    @susantkumar28892 жыл бұрын

    Hello Sir can you make Spring Security tutorial Using mongoDb

  • @akash0380
    @akash03803 жыл бұрын

    Please provide only real world examples who can actually solve the problem

Келесі