| | |
| | | { |
| | | label: "æ¥å¿åç§°", |
| | | prop: "logName", |
| | | width:'80', |
| | | width:'160', |
| | | }, |
| | | { |
| | | label: "æ¥å¿ç±»å", |
| | | prop: "logType" |
| | | prop: "logType", |
| | | width:'160' |
| | | }, |
| | | { |
| | | label: "å建æ¶é´", |
| | | prop: "createTime", |
| | | width:'180' |
| | | width:'160' |
| | | }, |
| | | { |
| | | label: "æåä¿®æ¹æ¶é´", |
| | | prop: "lastModifier", |
| | | width:'180' |
| | | width:'160' |
| | | } |
| | | ] |
| | | }, |
| | |
| | | permissionList() { |
| | | return { |
| | | delBtn: this.vaildData(this.permission.localLog.localLog_delete, false), |
| | | downLoadBtn: this.vaildData(this.permission.localLog.localLog_dwonload, false) |
| | | downLoadBtn: this.vaildData(this.permission.localLog.localLog_download, false) |
| | | }; |
| | | } |
| | | }, |
| | | methods: { |
| | | // 夿客æ·ç«¯æå¨çæä½ç³»ç»å¹³å° |
| | | isWindows() { |
| | | return navigator.platform.indexOf('Win') !== -1 |
| | | }, |
| | | // æ ¹æ®æä½ç³»ç»å¹³å°è¿åç¸åºçè·¯å¾åé符 |
| | | getPathSeparator() { |
| | | return this.isWindows() ? '\\' : '/' |
| | | }, |
| | | methods: { |
| | | |
| | | downLoadLogFile(row){ |
| | | this.downloadLoading = true; |
| | | let logPath = row.hasChildren ? row.logPath:row.logPath+this.getPathSeparator()+row.logName; |
| | | let logPath = row.hasChildren ? row.logPath:row.logPath+"\\"+row.logName; |
| | | downLoadLog(Object.assign({},row,{logFullPaths:logPath})).then(res=>{ |
| | | func.downloadFileByBlobHandler(res); |
| | | this.downloadLoading = false; |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import {getUsualList, getUsualLogs} from "@/api/logs"; |
| | | import { listLogOperate } from "@/api/logs"; |
| | | import {mapGetters} from "vuex"; |
| | | |
| | | export default { |
| | |
| | | form: {}, |
| | | selectionList: [], |
| | | query: {}, |
| | | //æ¯å¦æ¯ä¸å管çåæ¥å¿ |
| | | isAdmin: 0, |
| | | // LoginOrLogout:ç»å½æ¥å¿,auth:æææ¥å¿,operate:æä½æ¥å¿ |
| | | logType: "LoginOrLogout", |
| | | loading: true, |
| | | page: { |
| | | pageSize: 10, |
| | |
| | | column: [ |
| | | { |
| | | label: "ç¨æ·å", |
| | | prop: "serviceId", |
| | | prop: "userName", |
| | | search: true |
| | | }, |
| | | { |
| | | label: "å§å", |
| | | prop: "serverHost", |
| | | prop: "realName", |
| | | search: true |
| | | }, |
| | | { |
| | | label: "ç¨æ·id", |
| | | prop: "serverIp" |
| | | label: "ç¨æ·ip", |
| | | prop: "ip" |
| | | }, |
| | | { |
| | | label: "模å", |
| | | prop: "env", |
| | | width:'80' |
| | | prop: "model", |
| | | width:'160' |
| | | }, |
| | | { |
| | | label: "æ¶é´", |
| | | prop: "logLevel" |
| | | prop: "time" |
| | | }, |
| | | { |
| | | label: "æä½ç»æ", |
| | | prop: "logId" |
| | | prop: "operateResult" |
| | | }, |
| | | { |
| | | label: "æè¿°", |
| | | prop: "requestUri" |
| | | prop: "description" |
| | | }, |
| | | ] |
| | | }, |
| | |
| | | return { |
| | | viewBtn: this.vaildData(this.permission.log_usual.log_usual_view, false) |
| | | }; |
| | | } |
| | | }, |
| | | }, |
| | | methods: { |
| | | searchReset() { |
| | |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | }, |
| | | underscoreName(key) { |
| | | return key.replace(/([A-Z])/g, "_$1").toLowerCase(); |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (["edit", "view"].includes(type)) { |
| | |
| | | this.onLoad(this.page, this.query); |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | let conditionMaps = {}; |
| | | conditionMaps["conditionMap[is_admin]"] = this.isAdmin; |
| | | conditionMaps["conditionMap[log_type]"] = this.logType.trim(); |
| | | if (params) { |
| | | Object.keys(params).forEach((key) => { |
| | | conditionMaps["conditionMap[" + this.underscoreName(key) + "_like]"] = params[key].trim(); |
| | | }); |
| | | } |
| | | this.loading = true; |
| | | getUsualList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { |
| | | listLogOperate( |
| | | page.currentPage, |
| | | page.pageSize, |
| | | conditionMaps |
| | | ).then(res => { |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.launch.constant.TokenConstant; |
| | | import org.springblade.core.log.annotation.ApiLog; |
| | | import org.springblade.core.log.annotation.LoginOrLogoutLog; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.BladeUser; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.core.tool.utils.WebUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.authentication.InsufficientAuthenticationException; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.security.core.context.SecurityContextHolder; |
| | | import org.springframework.security.oauth2.common.OAuth2AccessToken; |
| | | import org.springframework.security.oauth2.common.OAuth2RefreshToken; |
| | | import org.springframework.security.oauth2.common.exceptions.InvalidClientException; |
| | | import org.springframework.security.oauth2.common.exceptions.InvalidGrantException; |
| | | import org.springframework.security.oauth2.common.exceptions.InvalidRequestException; |
| | | import org.springframework.security.oauth2.common.exceptions.UnsupportedGrantTypeException; |
| | | import org.springframework.security.oauth2.common.util.OAuth2Utils; |
| | | import org.springframework.security.oauth2.provider.AuthorizationRequest; |
| | | import org.springframework.security.oauth2.provider.ClientDetails; |
| | | import org.springframework.security.oauth2.provider.ClientDetailsService; |
| | | import org.springframework.security.oauth2.provider.TokenRequest; |
| | | import org.springframework.security.oauth2.provider.endpoint.TokenEndpoint; |
| | | import org.springframework.security.oauth2.provider.token.TokenStore; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.HttpRequestMethodNotSupportedException; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import java.security.Principal; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | import javax.servlet.http.HttpSession; |
| | | import java.time.Duration; |
| | |
| | | * éåºç»å½ |
| | | */ |
| | | @GetMapping("/oauth/logout") |
| | | @LoginOrLogoutLog("logout") |
| | | public Kv logout() { |
| | | BladeUser user = AuthUtil.getUser(); |
| | | String token = JwtUtil.getToken(WebUtil.getRequest().getHeader(TokenConstant.HEADER)); |
| | |
| | | |
| | | import com.alibaba.nacos.common.utils.StringUtils; |
| | | import com.vci.ubcs.auth.constant.AuthConstant; |
| | | import com.vci.ubcs.auth.support.BladePasswordEncoderFactories; |
| | | import com.vci.ubcs.auth.utils.TokenUtil; |
| | | import com.vci.ubcs.system.user.entity.User; |
| | | import com.vci.ubcs.system.user.entity.UserInfo; |
| | |
| | | import com.vci.ubcs.common.cache.CacheNames; |
| | | import org.springblade.core.jwt.JwtUtil; |
| | | import org.springblade.core.jwt.props.JwtProperties; |
| | | import org.springblade.core.log.annotation.LoginOrLogoutLog; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.api.R; |
| | |
| | | |
| | | @Override |
| | | @SneakyThrows |
| | | @LoginOrLogoutLog("login") |
| | | public BladeUserDetails loadUserByUsername(String username) { |
| | | HttpServletRequest request = WebUtil.getRequest(); |
| | | // è·åç¨æ·ç»å®ID |
| | |
| | | |
| | | //è¶
级管çåé
ç½®æä»¶é
置账å·å¯ç ï¼å®ç°ç»å½, é»è®¤ç§æ·idåè¶
管为é
ç½®åºæ¥ç |
| | | if(tenantId.equals(this.tenantId) && userName.equals(username)){ |
| | | if (!this.userName.equals(username) && !password.equalsIgnoreCase(this.password)) { |
| | | if (!this.userName.equals(username) || !BladePasswordEncoderFactories.createDelegatingPasswordEncoder().encode(password).equalsIgnoreCase(AuthConstant.ENCRYPT+this.password)) { |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND+"è¿æã"+(failCount-count)+"ãæ¬¡å°è¯æºä¼!"); |
| | | } |
| | | //妿ipæ¯å¯¹ågetæåºå¼å¸¸No value presentå°±ç´æ¥æå¼å¸¸ç»æç»å½ |
| | | if(ipEnable){ |
| | |
| | | // ç¨æ·ä¸åå¨,ä½æç¤ºç¨æ·åä¸å¯ç é误并éå®è´¦å· |
| | | if (user == null || user.getId() == null) { |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND+"è¿æã"+(failCount-count)+"ãæ¬¡å°è¯æºä¼!"); |
| | | } |
| | | // ç¨æ·ç¶æä¸º1æ¶è¯´æè¯¥ç¨æ·è¢«éå® |
| | | if(user.getUserStatus() == 1){ |
| | |
| | | // ç¨æ·åå¨ä½å¯ç é误,è¶
è¿æ¬¡æ°åéå®è´¦å· |
| | | if (grantType != null && !grantType.equals(TokenUtil.REFRESH_TOKEN_KEY) && !user.getPassword().equals(hex)) { |
| | | setFailCount(tenantId, username, count,strategy.getLockingTime()); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND); |
| | | throw new UsernameNotFoundException(TokenUtil.USER_NOT_FOUND+"è¿æã"+(failCount-count)+"ãæ¬¡å°è¯æºä¼!"); |
| | | } |
| | | // ç¨æ·è§è²ä¸åå¨ |
| | | if (Func.isEmpty(userInfo.getRoles())) { |
| | |
| | | /** |
| | | * ç¨æ·ä¿¡æ¯ç®¡çæå¡ |
| | | */ |
| | | UBCS_ADMIN("ubcs_user","æå¡æ²»çæå¡") |
| | | UBCS_ADMIN("ubcs_admin","æå¡æ²»çæå¡") |
| | | |
| | | ; |
| | | |
| | |
| | | * @author Chill |
| | | */ |
| | | @EnableDiscoveryClient |
| | | @EnableFeignClients(basePackages = {"com.vci.ubcs", "org.springblade"}) |
| | | @EnableFeignClients("org.springblade") |
| | | @SpringBootApplication |
| | | public class LogApplication { |
| | | |
| | |
| | | import com.vci.ubcs.starter.web.util.LangBaseUtil; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | package com.vci.ubcs.log.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.vci.ubcs.log.service.ILogOperateService; |
| | | import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.log.model.LogOperate; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | |
| | | /** |
| | | * æä½æ¥å¿ç®¡ç:(å
æ¬ç»å½æ¥å¿ãæä½æ¥å¿ãæææ¥å¿ï¼ä»¥å管çåç以ä¸ä¸ç§æ¥å¿) |
| | |
| | | @RequestMapping("/operateLog") |
| | | public class LogOperateController { |
| | | |
| | | private final ILogOperateService operateLogService; |
| | | |
| | | /** |
| | | * æ¥è¯¢æ¥å¿å表 |
| | | * @param bladeQueryObject |
| | | * @return |
| | | */ |
| | | @GetMapping("/listLogOperate") |
| | | public R<IPage<LogOperate>> listLogOperate(BladeQueryObject bladeQueryObject) { |
| | | return R.data(operateLogService.listByCondition(bladeQueryObject)); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.vci.ubcs.log.feign; |
| | | |
| | | |
| | | import org.springblade.core.log.model.LogOperate; |
| | | import com.vci.ubcs.log.service.ILogApiService; |
| | | import com.vci.ubcs.log.service.ILogErrorService; |
| | | import com.vci.ubcs.log.service.ILogOperateService; |
| | | import com.vci.ubcs.log.service.ILogUsualService; |
| | | import org.springblade.core.log.feign.ILogClient; |
| | | import org.springblade.core.log.model.LogError; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.log.model.LogApi; |
| | | import org.springblade.core.log.model.LogOperate; |
| | | import org.springblade.core.log.model.LogUsual; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springblade.core.tool.api.R; |
| | |
| | | |
| | | private final ILogErrorService errorLogService; |
| | | |
| | | private final ILogOperateService operateLogService; |
| | | |
| | | @Override |
| | | @PostMapping(API_PREFIX + "/saveUsualLog") |
| | | public R<Boolean> saveUsualLog(@RequestBody LogUsual log) { |
| | |
| | | return R.data(errorLogService.save(log)); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @PostMapping(API_PREFIX + "/saveOpereateLog") |
| | | public R<Boolean> saveOpereateLog(@RequestBody LogOperate logOperate) { |
| | | return R.data(operateLogService.saveLogOperate(logOperate)); |
| | | } |
| | | |
| | | } |
| | |
| | | package com.vci.ubcs.log.mapper; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.vci.ubcs.log.entity.LogOperate; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springblade.core.log.model.LogOperate; |
| | | |
| | | /** |
| | | * æä½æ¥å¿ç®¡ç:(å
æ¬ç»å½æ¥å¿ãæä½æ¥å¿ãæææ¥å¿ï¼ä»¥å管çåç以ä¸ä¸ç§æ¥å¿) |
| | |
| | | package com.vci.ubcs.log.service; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.vci.ubcs.log.entity.LogOperate; |
| | | import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.log.model.LogOperate; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * æä½æ¥å¿ç®¡ç:(å
æ¬ç»å½æ¥å¿ãæä½æ¥å¿ãæææ¥å¿ï¼ä»¥å管çåç以ä¸ä¸ç§æ¥å¿) |
| | |
| | | * @param bladeQueryObject |
| | | * @return |
| | | */ |
| | | List<LogOperate> listByCondition(BladeQueryObject bladeQueryObject) throws ServiceException; |
| | | IPage<LogOperate> listByCondition(BladeQueryObject bladeQueryObject) throws ServiceException; |
| | | |
| | | } |
| | |
| | | package com.vci.ubcs.log.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.baomidou.mybatisplus.extension.toolkit.SqlHelper; |
| | | import com.vci.ubcs.log.entity.LogOperate; |
| | | import com.vci.ubcs.log.mapper.LogOperateMapper; |
| | | import com.vci.ubcs.log.service.ILogOperateService; |
| | | import com.vci.ubcs.starter.util.UBCSCondition; |
| | | import com.vci.ubcs.starter.web.pagemodel.BladeQueryObject; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.log.model.LogOperate; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.secure.utils.AuthUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Locale; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | * @date 2023/11/24 10:51 |
| | | */ |
| | | @Service |
| | | public class LogOperateServiceImpl extends ServiceImpl<LogOperateMapper,LogOperate> implements ILogOperateService { |
| | | public class LogOperateServiceImpl extends ServiceImpl<LogOperateMapper, LogOperate> implements ILogOperateService { |
| | | |
| | | @Autowired |
| | | private LogOperateMapper logOperateMapper; |
| | |
| | | if(Func.isEmpty(logOperate)){ |
| | | return false; |
| | | } |
| | | // è·åå°è§è²åç§°å¤ææ¯å¦ä¸ºä¸å管çå |
| | | String userRole = AuthUtil.getUserRole().toLowerCase(Locale.ROOT); |
| | | userRole = Func.isBlank(userRole) ? logOperate.getUserName():userRole; |
| | | if(userRole.contains("auditadmin") || userRole.contains("sysadmin") || userRole.contains("secadmin") || userRole.contains("admin")){ |
| | | logOperate.setIsAdmin(1); |
| | | } |
| | | return SqlHelper.retBool(logOperateMapper.insert(logOperate)); |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<LogOperate> listByCondition(BladeQueryObject bladeQueryObject) throws ServiceException{ |
| | | public IPage<LogOperate> listByCondition(BladeQueryObject bladeQueryObject) throws ServiceException{ |
| | | Map<String, Object> conditionMap = bladeQueryObject.getConditionMap(); |
| | | if(conditionMap.isEmpty() || Func.isBlank(conditionMap.get("logType").toString())){ |
| | | // 主è¦ä¸ºäºåºåæ¯æä½æ¥å¿è¿æ¯ç»å½æ¥å¿ç |
| | | if(conditionMap.isEmpty() || Func.isBlank(conditionMap.get("log_type").toString())){ |
| | | throw new ServiceException("æ¥å¿æ¥è¯¢å¿
ä¼ åæ°ãæ¥å¿ç±»åãä¸è½ä¸ºç©ºï¼"); |
| | | } |
| | | // map对象转æ¢ä¸ºæ¥è¯¢å¯¹è±¡ |
| | | QueryWrapper<LogOperate> queryWrapper = Condition.getQueryWrapper(bladeQueryObject.getConditionMap(),LogOperate.class); |
| | | return this.list(queryWrapper); |
| | | IPage<LogOperate> logOperateIPage = this.logOperateMapper.selectPage(Condition.getPage(bladeQueryObject.getQuery().setDescs("TIME")), UBCSCondition.getQueryWrapper(bladeQueryObject.getConditionMap(), LogOperate.class)); |
| | | return logOperateIPage; |
| | | } |
| | | |
| | | } |
| | |
| | | * è·åæ å½¢èç¹ |
| | | * |
| | | * @param tenantId |
| | | * @param excludeRole |
| | | * @return |
| | | */ |
| | | List<RoleVO> roleList(String tenantId); |
| | |
| | | } |
| | | strategy.setUpdateTime(new Date()); |
| | | CacheUtil.clear(SYS_CACHE, Boolean.FALSE); |
| | | boolean temp1 = super.saveOrUpdate(strategy); |
| | | boolean temp1 = this.update(strategy,Wrappers.<Strategy>update().lambda().eq(Strategy::getId,strategy.getId())); |
| | | boolean temp2 = false; |
| | | if(Func.isNotEmpty(oldIsDefaultStrategy)){ |
| | | temp2 = updateUserStrategyDefault(temp1, oldIsDefaultStrategy); |