规范配置文件,添加接口鉴权的例外接口配置

This commit is contained in:
64850858
2021-07-06 16:38:31 +08:00
parent b24be12405
commit 0faa593658
11 changed files with 2471 additions and 16568 deletions

View File

@@ -10,55 +10,55 @@ public class MediaConfig {
@Value("${media.ip}")
private String ip;
@Value("${media.hookIp:${sip.ip}}")
@Value("${media.hook-ip:${sip.ip}}")
private String hookIp;
@Value("${sip.ip}")
private String sipIp;
@Value("${media.sdpIp:${media.ip}}")
@Value("${media.sdp-ip:${media.ip}}")
private String sdpIp;
@Value("${media.streamIp:${media.ip}}")
@Value("${media.stream-ip:${media.ip}}")
private String streamIp;
@Value("${media.httpPort}")
@Value("${media.http-port}")
private Integer httpPort;
@Value("${media.httpSSlPort:}")
@Value("${media.http-ssl-port:}")
private Integer httpSSlPort;
@Value("${media.rtmpPort:}")
@Value("${media.rtmp-port:}")
private Integer rtmpPort;
@Value("${media.rtmpSSlPort:}")
@Value("${media.rtmp-ssl-port:}")
private Integer rtmpSSlPort;
@Value("${media.rtpProxyPort:}")
@Value("${media.rtp-proxy-port:}")
private Integer rtpProxyPort;
@Value("${media.rtspPort:}")
@Value("${media.rtsp-port:}")
private Integer rtspPort;
@Value("${media.rtspSSLPort:}")
@Value("${media.rtsp-ssl-port:}")
private Integer rtspSSLPort;
@Value("${media.autoConfig:true}")
@Value("${media.auto-config:true}")
private boolean autoConfig;
@Value("${media.secret}")
private String secret;
@Value("${media.streamNoneReaderDelayMS:18000}")
@Value("${media.stream-none-reader-delay-ms:18000}")
private String streamNoneReaderDelayMS;
@Value("${media.rtp.enable}")
private boolean rtpEnable;
@Value("${media.rtp.portRange}")
@Value("${media.rtp.port-range}")
private String rtpPortRange;
@Value("${media.recordAssistPort}")
@Value("${media.record-assist-port}")
private Integer recordAssistPort;
public String getIp() {

View File

@@ -13,7 +13,7 @@ public class SipConfig {
/**
* 默认使用sip.ip
*/
@Value("${sip.monitorIp:0.0.0.0}")
@Value("${sip.monitor-ip:0.0.0.0}")
private String monitorIp;
@Value("${sip.port}")
@@ -31,10 +31,10 @@ public class SipConfig {
@Value("${sip.ptz.speed:50}")
Integer speed;
@Value("${sip.keepaliveTimeOut:180}")
@Value("${sip.keepalive-timeout:180}")
Integer keepaliveTimeOut;
@Value("${sip.registerTimeInterval:60}")
@Value("${sip.register-time-interval:60}")
Integer registerTimeInterval;
public String getMonitorIp() {

View File

@@ -1,60 +1,130 @@
package com.genersoft.iot.vmp.conf;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
@Configuration("userSetup")
import java.util.ArrayList;
import java.util.List;
//@Configuration("userSetup")
//public class UserSetup {
// @Value("${userSettings.savePositionHistory:false}")
// boolean savePositionHistory;
//
// @Value("${userSettings.autoApplyPlay}")
// private boolean autoApplyPlay;
//
// @Value("${userSettings.seniorSdp:false}")
// private boolean seniorSdp;
//
// @Value("${userSettings.playTimeout:18000}")
// private long playTimeout;
//
// @Value("${userSettings.waitTrack:false}")
// private boolean waitTrack;
//
// @Value("${userSettings.interfaceAuthentication}")
// private boolean interfaceAuthentication;
//
// @Value("${userSettings.recordPushLive}")
// private boolean recordPushLive;
//
// @Value("${userSettings.interfaceAuthenticationExcludes:}")
// private String interfaceAuthenticationExcludes;
//
// public boolean getSavePositionHistory() {
// return savePositionHistory;
// }
//
// public boolean isSavePositionHistory() {
// return savePositionHistory;
// }
//
// public boolean isAutoApplyPlay() {
// return autoApplyPlay;
// }
//
// public boolean isSeniorSdp() {
// return seniorSdp;
// }
//
// public long getPlayTimeout() {
// return playTimeout;
// }
//
// public boolean isWaitTrack() {
// return waitTrack;
// }
//
// public boolean isInterfaceAuthentication() {
// return interfaceAuthentication;
// }
//
// public boolean isRecordPushLive() {
// return recordPushLive;
// }
//
// public String getInterfaceAuthenticationExcludes() {
// return interfaceAuthenticationExcludes;
// }
//}
@Component
@ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true)
public class UserSetup {
@Value("${userSettings.savePositionHistory:false}")
boolean savePositionHistory;
@Value("${userSettings.autoApplyPlay}")
private boolean autoApplyPlay;
private Boolean savePositionHistory = Boolean.FALSE;
@Value("${userSettings.seniorSdp:false}")
private boolean seniorSdp;
private Boolean autoApplyPlay = Boolean.FALSE;
@Value("${userSettings.playTimeout:18000}")
private long playTimeout;
private Boolean seniorSdp = Boolean.FALSE;
@Value("${userSettings.waitTrack:false}")
private boolean waitTrack;
private Long playTimeout = 18000L;
@Value("${userSettings.interfaceAuthentication}")
private boolean interfaceAuthentication;
private Boolean waitTrack = Boolean.FALSE;
@Value("${userSettings.recordPushLive}")
private boolean recordPushLive;
private Boolean interfaceAuthentication = Boolean.TRUE;
public boolean getSavePositionHistory() {
private Boolean recordPushLive = Boolean.FALSE;
private List<String> interfaceAuthenticationExcludes = new ArrayList<>();
public Boolean getSavePositionHistory() {
return savePositionHistory;
}
public boolean isSavePositionHistory() {
public Boolean isSavePositionHistory() {
return savePositionHistory;
}
public boolean isAutoApplyPlay() {
public Boolean isAutoApplyPlay() {
return autoApplyPlay;
}
public boolean isSeniorSdp() {
public Boolean isSeniorSdp() {
return seniorSdp;
}
public long getPlayTimeout() {
public Long getPlayTimeout() {
return playTimeout;
}
public boolean isWaitTrack() {
public Boolean isWaitTrack() {
return waitTrack;
}
public boolean isInterfaceAuthentication() {
public Boolean isInterfaceAuthentication() {
return interfaceAuthentication;
}
public boolean isRecordPushLive() {
public Boolean isRecordPushLive() {
return recordPushLive;
}
public List<String> getInterfaceAuthenticationExcludes() {
return interfaceAuthenticationExcludes;
}
}

View File

@@ -14,6 +14,8 @@ import org.springframework.security.config.annotation.web.configuration.EnableWe
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import java.util.List;
/**
* 配置Spring Security
*/
@@ -85,6 +87,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/swagger-resources/**")
.antMatchers("/v3/api-docs/**")
.antMatchers("/js/**");
List<String> interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes();
System.out.println(interfaceAuthenticationExcludes.size());
for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) {
web.ignoring().antMatchers(interfaceAuthenticationExclude);
}
}
}