Spring Security Basic authentication for a single path next to token authentication -
i have custom resourceservertokenservices in place:
@configuration public class cloudsecurityconfig { @bean protected myresourceservertokenservices() { return new myresourceservertokenservices(); } }
then have follogin resourceserverconfigureradapter:
@configuration @enablewebsecurity @enableresourceserver @enableglobalmethodsecurity(prepostenabled = true) public class securityresourceconfiguration extends resourceserverconfigureradapter { @override public void configure(httpsecurity http) throws exception { http.sessionmanagement().sessioncreationpolicy(sessioncreationpolicy.never); http.authorizerequests().accessdecisionmanager(accessdecisionmanager()) .antmatchers("/h2-console/**").anonymous() .antmatchers("/health/**").permitall() .antmatchers("/v*/api-docs").permitall().anyrequest() .authenticated().and().httpbasic().and().headers() .frameoptions().disable(); } @bean protected unanimousbased accessdecisionmanager() { list<accessdecisionvoter<? extends object>> voterlist = new arraylist<>(); webexpressionvoter expressionvoter = new webexpressionvoter(); expressionvoter.setexpressionhandler(new oauth2websecurityexpressionhandler()); voterlist.add(expressionvoter); voterlist.add(new authenticatedvoter()); return new unanimousbased(voterlist); } }
now need add basic authentication (with inmemory credentials) 1 single endpoint (lets /myendpoint**). how can achieve this?
thanks!
Comments
Post a Comment