Solon v2.7.5

grit-solon-plugin

</> markdown
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>grit-solon-plugin</artifactId>
</dependency>

1、描述

基础扩展插件,为 grit (代码仓库)权限管理进行适配。在适配过程中,采用了 solon.auth 做为对接标准。

2、使用示例

//适配签权处理器
public class AuthProcessorImpl extends GritAuthProcessor {
    @Override
    protected long getSubjectId() {
        return Session.current().getSubjectId();
    }
}

//构建签权适配器
@Configuration
public class Config {
    @Bean
    public AuthAdapter initAuth() {
        return new AuthAdapter()
                .loginUrl("/login") //设定登录地址,未登录时自动跳转
                //.addRule(r -> r.include("**").verifyIp().failure((c, t) -> c.output("你的IP不在白名单"))) //添加规则
                //.addRule(b -> b.exclude("/login**").exclude("/_**").verifyPath()) //添加规则
                .processor(new AuthProcessorImpl()) //设定认证处理器
                .failure((ctx, rst) -> { //设定默认的验证失败处理
                    ctx.render(rst);
                });
    }
}

具体可参考:https://gitee.com/noear/grit/tree/main/example