Monday, 10 December 2018

Disabling Spring Security if you don't require it

When using Spring Cloud Services Starter Config Client dependency for example Spring Security will also be included (Config servers will be protected by OAuth2). As a result this will also enable basic authentication to all our service endpoints on your application which may not be the desired result here if your just building a demo for example

Add the following to conditionally disable security in your Spring Boot main class

package com.example.employeeservice;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.annotation.Configuration;

public class EmployeeServiceApplication {

    public static void main(String[] args) {, args);

    static class ApplicationSecurity extends WebSecurityConfigurerAdapter {

        public void configure(WebSecurity web) throws Exception {

No comments: