ResourceServerConfig.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package com.ym.config;
  2. import com.ym.mec.common.security.BaseAccessDeniedHandler;
  3. import com.ym.mec.common.security.BaseAuthenticationEntryPoint;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.security.config.annotation.web.builders.HttpSecurity;
  7. import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
  8. import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
  9. import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
  10. @Configuration
  11. @EnableResourceServer
  12. public class ResourceServerConfig extends ResourceServerConfigurerAdapter {
  13. @Autowired
  14. private BaseAccessDeniedHandler baseAccessDeniedHandler;
  15. @Autowired
  16. private BaseAuthenticationEntryPoint baseAuthenticationEntryPoint;
  17. @Override
  18. public void configure(HttpSecurity http) throws Exception {
  19. http.authorizeRequests().antMatchers("/v2/api-docs", "/user/register",
  20. "/group/join", "/group/create", "/group/quit", "/room/leave", "/room/statusSync",
  21. "/room/statusImMsg", "/group/batchDismiss", "/private/send", "/group/send", "/user/tencentImCallback",
  22. "/group/dismiss", "/room/statusImMsg", "/history/get", "/user/statusImUser", "/liveRoom/recordSync",
  23. "/liveRoom/publishRoomMsg", "/liveRoom/destroy", "/liveRoom/create", "/liveRoom/startRecord",
  24. "/liveRoom/stopRecord", "/liveRoom/userExistInRoom","/liveRoom/checkOnline","/room/statusSyncTencent",
  25. "/user/tencentStreamEventCallback", "/user/tencentStreamRecordCallback", "/user/tencentStreamExceptionCallback",
  26. "/liveRoom/addUserUnableSpeak","/liveRoom/removeUserUnableSpeak","/liveRoom/syncChatRoomStatus","/liveRoom/tencentImCallback")
  27. .permitAll().anyRequest().authenticated().and().csrf().disable();
  28. }
  29. @Override
  30. public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
  31. resources.authenticationEntryPoint(baseAuthenticationEntryPoint).accessDeniedHandler(baseAccessDeniedHandler);
  32. }
  33. }