天天看點

五分鐘帶你玩轉oauth2(二十一)spring security+oauth2資源伺服器開放swaager通路

五分鐘帶你玩轉oauth2(二十一)spring security+oauth2資源伺服器開放swaager通路
http.sessionManagement()
            // SpringSecurity不會使用也不會建立HttpSession執行個體
            .sessionCreationPolicy(SessionCreationPolicy.STATELESS).and().authorizeRequests()
            // swagger請求
            .antMatchers("/swagger-ui.html", "/webjars/**", "/swagger-resources/**","/v2/**").permitAll()
            // 所有請求,都需要有all範圍(scope)
            .antMatchers("/**").access("#oauth2.hasScope('xxx')").anyRequest().authenticated().and().csrf()
            .disable();