V2EX src112159 的所有回复 第 1 页 / 共 1 页
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX    src112159    全部回复第 1 页 / 共 1 页
回复总数  20
试试 i3wm 桌面呢,或者 i3wm 的迭代版 sway 。都很轻量啊,目前 arch+i3wm 感觉还行
2024 年 7 月 7 日
回复了 keepongjl 创建的主题 职场话题 行情真的这么差吗?
去年被毕业,躺了 8 个月了
似乎没人说谷歌硬盘。
2020 年 2 月 21 日
回复了 seanxx 创建的主题 MacBook Pro macbookpro 出现爆裂噼里啪啦声音
排除法看看
2019 年 4 月 4 日
回复了 KHfqLAYYS6BKJT3R 创建的主题 生活 耳鸣一个多月了,好烦
是身体太虚引起的,我有过这样的经历,去医院检查也没啥毛病。大部分原因是心理压力和营养不够造成的
个人感觉比 MAC 版的 SecureCRT 好用
ZOC7,我现在在用的,推荐试试
2018 年 12 月 26 日
回复了 heraldic 创建的主题 Linux deepin Linux 确实好用,暂时整机就用它了
PC 装个黑苹果其实还不错,远景上有很多别人做好的引导
就是因为那个返回的 code 的原因,返回 1001 前段直接 logout 了。。。。
@beny2mor

已经找到问题了,谢谢你的帮助哈,。
@beny2mor
@Service
public class MyAccessDecisionManager implements AccessDecisionManager {


@Override
public void decide(Authentication authentication, Object object, Collection<ConfigAttribute> configAttributes) throws AccessDeniedException, InsufficientAuthenticationException {
if(null == configAttributes || configAttributes.size() <= 0) {
return;
}
ConfigAttribute c;
String needRole;
for(Iterator<ConfigAttribute> iter = configAttributes.iterator(); iter.hasNext(); ) {
c = iter.next();
needRole = c.getAttribute();
for(GrantedAuthority ga : authentication.getAuthorities()) {
if(needRole.trim().equals(ga.getAuthority())) {
return;
}
}
}
throw new AccessDeniedException("没有操作权限");
}

@Override
public boolean supports(ConfigAttribute attribute) {
return true;
}

@Override
public boolean supports(Class<?> clazz) {
return true;
}
}


----------------------------------------------------------------


@Component
public class MyAccessDeniedHandler implements AccessDeniedHandler {
@Override
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) throws IOException, ServletException {
//返回 json 形式的错误信息
response.setCharacterEncoding("UTF-8");
response.setContentType("application/json");
response.getWriter().println("{\"code\":1001, \"msg\":\""+e.getMessage()+"\"}");
response.getWriter().flush();
}
}


----------------------------------------------------------
是有 AccessDecisionManager 的,无权限的资源也返回了这个 json,现在就是会自己跳转到登录
@beny2mor 这样权限控制好像是没有问题的,但就是会跳转到自定义的登录页面
@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
httpSecurity
// 由于使用的是 JWT,我们这里不需要 csrf
.csrf().disable()

.exceptionandling()
.accessDeniedHandler(myAccessDeniedHandler)
.authenticationEntryPoint(unauthorizedHandler)
.and()

// 基于 token,所以不需要 session
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()

.authorizeRequests()

// 允许对于网站静态资源的无授权访问
.antMatchers(
HttpMethod.GET,
"/",
"/*.html",
"/favicon.ico",
"/**/*.html",
"/**/*.css",
"/**/*.js",
"/**/*.png",
"/**/*.jpg"
).permitAll()
// 对于获取 token 的 rest api 要允许匿名访问
.antMatchers("/api/auth/**").permitAll()
.antMatchers("/sys_user/**").permitAll()
.antMatchers("/x_mgr/**/*.*").permitAll()
// 除上面外的所有请求全部需要鉴权认证
.anyRequest().authenticated();

// 添加 JWT filter
httpSecurity
.addFilterBefore(authenticationTokenFilterBean(), UsernamePasswordAuthenticationFilter.class);
httpSecurity.addFilterBefore(myFilterSecurityInterceptor, FilterSecurityInterceptor.class);
// 禁用缓存
httpSecurity.headers().cacheControl();
}
是跳转到了自定义的登录页。我现在就是在数据库配置了用户-资源权限表,用表里的资源来控制的
也有没有权限的返回值 json。 但就是不知道它为啥还会跳转到登录页
@beny2mor httpSecurity
.csrf().disable()

.exceptionHandling()
.authenticationEntryPoint(unauthorizedHandler)
.accessDeniedHandler(myAccessDeniedHandler)

这个是有配置了的。
我在这个 URL 对应的方法上面加注解 @PreAuthorize("hasRole('ROLE_CO')") ,就能实现不跳转。直接返回 json
2018 年 2 月 21 日
回复了 rajiha 创建的主题 全球工单系统 网易云音乐部分页面/API 疑似炸了?
网管搞得鬼吧,在路由上过滤了
2018 年 2 月 8 日
回复了 liuzl 创建的主题 Python Python 技术公众号 100 天了
大力出奇迹。
我就来
2018 年 2 月 7 日
回复了 FourAndHalf 创建的主题 Ubuntu 小米笔记本 Pro 能完美支持 Ubuntu 吗
就算装 Ubuntu 完美驱动,不会觉得软件不够用吗
关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     2568 人在线   最高记录 6679       Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 46ms UTC 01:51 PVG 09:51 LAX 18:51 JFK 21:51
Do have faith in what you're doing.
ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86