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

Sdílet
Vložit
  • čas přidán 9. 05. 2018
  • 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
  • Věda a technologie

Komentáře • 291

  • @leawitkiewicz
    @leawitkiewicz Před 4 lety +2

    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

  • @niharrjpattanayak4406
    @niharrjpattanayak4406 Před 4 lety +8

    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

  • @kabira__shaikh
    @kabira__shaikh Před 6 lety +2

    Really appreciable work Basanta :) Thanks for this one.

  • @Aguuuu91
    @Aguuuu91 Před 3 lety +1

    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
    @ikhbayar1000 Před 4 lety +1

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

  • @theritesh973
    @theritesh973 Před 6 lety +1

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

  • @sonamkumari-jj7yj
    @sonamkumari-jj7yj Před 4 lety +1

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

  • @krishnavidala7296
    @krishnavidala7296 Před 5 lety +1

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

  • @wf3644
    @wf3644 Před 3 lety +2

    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

  • @benvinertt2150
    @benvinertt2150 Před 3 lety +1

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

  • @akashpisal3582
    @akashpisal3582 Před 2 lety +1

    Thanks for quick tutorial and to the point.

  • @ashwinkumar504
    @ashwinkumar504 Před 4 lety +1

    Good one Thanks for the post

  • @umamaheswarreddy9204
    @umamaheswarreddy9204 Před 3 lety +1

    OMG ! you solved my problem.Thank you so much

  • @Javatechie
    @Javatechie  Před 5 lety +1

    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 Před 4 lety +1

      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  Před 4 lety

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

    • @sawankumarpanigrahi9949
      @sawankumarpanigrahi9949 Před 4 lety

      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 Před 4 lety

      yes sir do repeat it

    • @Javatechie
      @Javatechie  Před 4 lety

      @@vikaspooner9846 ok I will do that

  • @aniketaglawe8585
    @aniketaglawe8585 Před 3 lety +1

    KEEP IT UP ..LOVE IT

  • @asamhemanthkumar
    @asamhemanthkumar Před 3 lety +1

    Very informative tutorial 👍👍👍👍

  • @maheshwaghmare2312
    @maheshwaghmare2312 Před 5 lety +1

    Thank you sir very nice explanation and demonstration

  • @oumaimakabouri3491
    @oumaimakabouri3491 Před 4 lety +1

    Many thanks for this video.

  • @dakshsaini8274
    @dakshsaini8274 Před 3 lety +1

    Thanks man for this great tutorial

  • @user-rh7fg5gn4b
    @user-rh7fg5gn4b Před 5 lety +1

    awesome tutorial dear man

  • @sumantmishra3207
    @sumantmishra3207 Před rokem +1

    Thank you for sharing so much knowledge with us

  • @keymalerock
    @keymalerock Před 4 lety +4

    thanks bro. you really help mankind

  • @hippiestafarii
    @hippiestafarii Před 5 lety +1

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

  • @srinathn1600
    @srinathn1600 Před 6 lety +1

    Good work

  • @przemysawkaleta4053
    @przemysawkaleta4053 Před 4 lety +1

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

  • @vinodnayak27
    @vinodnayak27 Před rokem

    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

  • @gauravk002
    @gauravk002 Před 2 lety +1

    You are a exceptional person..

  • @brice3002
    @brice3002 Před 3 lety +1

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

    • @Javatechie
      @Javatechie  Před 3 lety +1

      Hi Dorsey , this is video is more clear please have a look remake version
      czcams.com/video/SpBHdWvRKZ8/video.html

    • @brice3002
      @brice3002 Před 3 lety +1

      @@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  Před 3 lety +1

      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

  • @nagireddy1507
    @nagireddy1507 Před 5 lety +1

    thanks alot bro....

  • @mc1aify
    @mc1aify Před 4 lety +2

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

  • @jyotsanarai6715
    @jyotsanarai6715 Před rokem

    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 .

  • @helletuxen3751
    @helletuxen3751 Před 5 lety +1

    nice love it

  • @kingkhan-jp9zv
    @kingkhan-jp9zv Před 2 lety +1

    this is the best ..please make videos in hindi

  • @TheSunRise-PS
    @TheSunRise-PS Před rokem +1

    Good :)

  • @basitali9651
    @basitali9651 Před 3 lety +1

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

  • @gourishankarmohanty3927
    @gourishankarmohanty3927 Před 5 lety +1

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

    • @Javatechie
      @Javatechie  Před 5 lety

      Sure will do it soon.

    • @JavaLovers
      @JavaLovers Před 5 lety +1

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

    • @Javatechie
      @Javatechie  Před 5 lety

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

  • @amansheikh1801
    @amansheikh1801 Před 2 lety +1

    thanks

  • @arkaimps
    @arkaimps Před 4 lety +1

    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  Před 4 lety

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

    • @arkaimps
      @arkaimps Před 4 lety

      @@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

  • @tareque540
    @tareque540 Před rokem +1

    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  Před rokem +1

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

  • @naveenparmar5328
    @naveenparmar5328 Před 2 lety +1

    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.

  • @karthikm7875
    @karthikm7875 Před 4 lety +6

    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 Před 3 lety

      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

  • @gautamsnegi27
    @gautamsnegi27 Před 4 lety

    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?

  • @kallamrajareddy
    @kallamrajareddy Před 6 lety +1

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

  • @maheshwaghmare2312
    @maheshwaghmare2312 Před 5 lety

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

  • @vikaspooner9846
    @vikaspooner9846 Před 3 lety +1

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

  • @akash0380
    @akash0380 Před 3 lety +2

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

  • @kumarmanish9046
    @kumarmanish9046 Před 4 lety +1

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

  • @aayushkc2306
    @aayushkc2306 Před 4 lety +2

    plz make the full playlist on thymeleaf

    • @Javatechie
      @Javatechie  Před 4 lety +1

      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 Před 4 lety

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

  • @madhumitanaskar962
    @madhumitanaskar962 Před 3 lety +1

    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  Před 3 lety +1

      Yes please checkout my latest spring security video

  • @dp-sg8hc
    @dp-sg8hc Před 3 lety +2

    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  Před 3 lety +1

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

  • @AhmedMkhinini
    @AhmedMkhinini Před 6 lety +1

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

    • @Javatechie
      @Javatechie  Před 6 lety

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

  • @omkarpalekar4237
    @omkarpalekar4237 Před 3 lety +1

    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  Před 3 lety

      Please checkout this
      czcams.com/video/SpBHdWvRKZ8/video.html

  • @AskirAskanon
    @AskirAskanon Před 4 lety

    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  Před 4 lety

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

    • @AskirAskanon
      @AskirAskanon Před 4 lety

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

    • @AskirAskanon
      @AskirAskanon Před 4 lety

      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  Před 4 lety

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

    • @AskirAskanon
      @AskirAskanon Před 4 lety

      @@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!!

  • @kumarmanish9046
    @kumarmanish9046 Před 4 lety

    14:00 what is the use of disabling csrf ?

  • @shad7764
    @shad7764 Před 4 lety +1

    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 Před 4 lety +1

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

    • @Javatechie
      @Javatechie  Před 4 lety

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

    • @RanjithKumar-qj9mn
      @RanjithKumar-qj9mn Před 4 lety

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

  • @rakeshyadav7079
    @rakeshyadav7079 Před 4 lety

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

  • @79EasyE
    @79EasyE Před 3 lety +1

    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.

  • @sujithg5873
    @sujithg5873 Před 4 lety +2

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

    • @Javatechie
      @Javatechie  Před 4 lety

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

  • @rameshbabu5754
    @rameshbabu5754 Před 4 lety

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

    • @vinodnayak27
      @vinodnayak27 Před rokem +1

      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  Před rokem

      Vinod can you check my spring security internal flow video

  • @shubhamnavghare1937
    @shubhamnavghare1937 Před 3 lety +1

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

  • @alisacrowe6063
    @alisacrowe6063 Před 4 lety +2

    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  Před 4 lety

      Did you check out my code ?

    • @alisacrowe6063
      @alisacrowe6063 Před 4 lety

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

    • @alisacrowe6063
      @alisacrowe6063 Před 4 lety

      Are you having the same problem that I am having?

    • @alisacrowe6063
      @alisacrowe6063 Před 4 lety

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

  • @AmandeepSingh-sx9ke
    @AmandeepSingh-sx9ke Před 5 lety +1

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

    • @Javatechie
      @Javatechie  Před 5 lety

      Use regular expression and replaceAll

  • @rudranarayandash1466
    @rudranarayandash1466 Před 4 lety

    do we need DaoAuthenticationProvider ?

  • @zhrgci
    @zhrgci Před 2 lety

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

  • @vikaspooner9846
    @vikaspooner9846 Před 4 lety +1

    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 Před 4 lety

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

  • @susantkumar2889
    @susantkumar2889 Před 2 lety +1

    Hello Sir can you make Spring Security tutorial Using mongoDb

  • @gangadharkodi5568
    @gangadharkodi5568 Před 3 lety +1

    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  Před 3 lety

      Why what is the problem any error ?

  • @kundanprasad8951
    @kundanprasad8951 Před 3 lety +1

    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  Před 3 lety

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

  • @gauravkumardwivedi2290
    @gauravkumardwivedi2290 Před 4 lety +1

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

    • @Javatechie
      @Javatechie  Před 4 lety +1

      One to many

    • @yacc8339
      @yacc8339 Před 3 lety

      @@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.

  • @RohitShindes
    @RohitShindes Před 4 lety

    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 Před 3 lety

      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?

  • @JavaLovers
    @JavaLovers Před 5 lety +2

    @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 Před 5 lety

      I am getting the same issue

    • @Javatechie
      @Javatechie  Před 5 lety

      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 Před 4 lety +1

      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 Před 3 lety

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

  • @pankajsharma-rf1ov
    @pankajsharma-rf1ov Před 3 lety +3

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

    • @basitali9651
      @basitali9651 Před 3 lety

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

  • @silviupopa2895
    @silviupopa2895 Před 3 lety +1

    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  Před 3 lety

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

    • @silviupopa2895
      @silviupopa2895 Před 3 lety

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

  • @dharmendrasm
    @dharmendrasm Před 2 lety

    are you from odisha

  • @jaysurya1190
    @jaysurya1190 Před měsícem

    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

  • @shalumariamsheji
    @shalumariamsheji Před 3 lety

    can u share db schema used for this?

  • @atharvamishra4848
    @atharvamishra4848 Před 3 lety +1

    @Java Techie why you reply only to those , whose problem Is solved your explanation is good but some time it not worked for everyone so please try to help those who are stuck...
    If I am learning from you or anyone learning with you is your student please don't treat your students like this....
    Just a suggestion please don't mind
    Please pardon me my words feel you bad....
    Good luck

    • @Javatechie
      @Javatechie  Před 3 lety +1

      Hi Atharva , I never mind .
      First of all I can help only if I know the answer of it .
      If you observe my video am doing live coding it's not I coded before and sharing screen right ?
      If same thing worked in my machine why not in your machine that you need to think and you need to find out the mistake you did.then only you can learn .
      Moral : am happy to help if I have answer .🙏

    • @atharvamishra4848
      @atharvamishra4848 Před 3 lety +1

      @Java Techie my application is running fine but when I am passing url in chrome it ask me for username and password and then it gives me 404 forbidden error on browser but in IDE console it is some thingh like
      Circular path view error
      Please help if you can...
      Becoz i am prepairing for job interviews...
      Thanks in advance....

    • @Javatechie
      @Javatechie  Před 3 lety +1

      Did you enable security if yes obviously it will ask you username and password
      Try with valid credential then if you are getting any error please copy past error stack here

  • @lngwnd1
    @lngwnd1 Před 4 lety +4

    Everything worked well for me except the last step where you added a user with the admin user.. I am not understanding why I am getting the 200 http status code like you but not the user successfully added message when I login as the ADMIN

  • @sushantgupta6786
    @sushantgupta6786 Před 5 lety +1

    I am able to login with incorrect username/password combination. Controller is checking only for username not the password. Can you please let me know he problem?

    • @Javatechie
      @Javatechie  Před 5 lety

      Based on email id it will fetch complete used object to validate on UserDetailsService that's the implementation I did in this tutorial,and just varify once whether are you able to see query in console or not ? It will be more easy if you can share your code with database schema in Github so that I can check this issue

  • @pragyanshreedas23594
    @pragyanshreedas23594 Před 3 lety

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

  • @sagarsaud156
    @sagarsaud156 Před 2 lety

    How to implement auto login after sign up process?

  • @rafiq742
    @rafiq742 Před 2 lety

    Thoese who still getting authorization related issue,
    modify following files:
    SecurityConfig.java --> change
    http.authorizeRequests().antMatchers("/rest/**").....
    to
    http.httpBasic().and().authorizeRequests().antMatchers("/rest/**").....
    CustomUserDetails.java -->
    SimpleGrantedAuthority("ROLE_" + role).antMatchers("/rest/**")
    to
    SimpleGrantedAuthority("ROLE_" + role.getRole())

  • @yashwanthreddygowreddigari1997

    Why @ getter @ setter you can use @ data directly

  • @hemagogawale6988
    @hemagogawale6988 Před rokem +1

    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  Před rokem

      Please check out this czcams.com/video/SpBHdWvRKZ8/video.html

  • @adnan93khan
    @adnan93khan Před 4 lety

    I am not able to mapped RequestMappingHandlerMapping

  • @gauravverma5475
    @gauravverma5475 Před 4 lety

    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.

  • @mohankadam1070
    @mohankadam1070 Před rokem +1

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

    • @Javatechie
      @Javatechie  Před rokem

      Please check out the session below 👇
      czcams.com/video/5jDrBD4Y1MI/video.html

    • @mohankadam1070
      @mohankadam1070 Před rokem +1

      @@Javatechie WebSecurityConfigrurerAdapter is now depreciated, refer spring documents

  • @shreyanshrathi6051
    @shreyanshrathi6051 Před 5 lety +2

    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  Před 5 lety

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

    • @mehdiqanbarzade4530
      @mehdiqanbarzade4530 Před 5 lety

      how you resolve this problem?

    • @mehdiqanbarzade4530
      @mehdiqanbarzade4530 Před 5 lety

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

    • @Javatechie
      @Javatechie  Před 5 lety

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

  • @msrao8884
    @msrao8884 Před 4 lety +1

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

  • @kallamrajareddy
    @kallamrajareddy Před 6 lety +2

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

    • @Javatechie
      @Javatechie  Před 6 lety

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

    • @kallamrajareddy
      @kallamrajareddy Před 6 lety

      but i am using ADMIN role

    • @kallamrajareddy
      @kallamrajareddy Před 6 lety

      i am trying with ORACLE

    • @wallacebarbosa26
      @wallacebarbosa26 Před 6 lety +3

      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  Před 6 lety

      wallace please check in UserDetailsServive already mentioned

  • @mansisd_world1115
    @mansisd_world1115 Před 2 lety

    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  Před 2 lety

      Check below video czcams.com/video/SpBHdWvRKZ8/video.html

    • @Javatechie
      @Javatechie  Před 2 lety

      Part 2 czcams.com/video/tEbHTc8BOaQ/video.html

  • @apegedara6060
    @apegedara6060 Před 4 lety

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

  • @siddharthausekar9196
    @siddharthausekar9196 Před 4 lety +1

    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

  • @krishnaeditz3462
    @krishnaeditz3462 Před 2 lety +1

    have you added custom login page..?

  • @abijithgs3132
    @abijithgs3132 Před 3 lety +1

    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  Před 3 lety

      Are you able to see DB query in console ?

    • @abijithgs3132
      @abijithgs3132 Před 3 lety +1

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

    • @Javatechie
      @Javatechie  Před 3 lety

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

    • @abijithgs3132
      @abijithgs3132 Před 3 lety

      @@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 Před 2 lety

      i am also getting the same issue

  • @lovebarua8277
    @lovebarua8277 Před 5 lety

    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  Před 5 lety

      It seems some firewall issue

    • @lovebarua8277
      @lovebarua8277 Před 5 lety

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

    • @Javatechie
      @Javatechie  Před 5 lety

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

  • @tienta8053
    @tienta8053 Před 4 lety +1

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

    • @Javatechie
      @Javatechie  Před 4 lety

      Hi we can configure , which version you are using?

    • @tienta8053
      @tienta8053 Před 4 lety

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

    • @Javatechie
      @Javatechie  Před 4 lety

      @@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 Před 4 lety

      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 Před 4 lety

      @@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();

  • @3infob525
    @3infob525 Před 4 lety

    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 !!!!!

  • @ajaydhami5631
    @ajaydhami5631 Před 4 lety +1

    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 Před 4 lety

      Me too, did you fixed it ?

    • @robertodelcampo5462
      @robertodelcampo5462 Před 4 lety

      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();


      }

  • @muhammadarshad574
    @muhammadarshad574 Před 3 lety +1

    I unable to find your kubernates video, can you pls share the link :-)