This commit is contained in:
MaxKey
2021-12-14 12:38:06 +08:00
parent c490551aef
commit de702ada8e
53 changed files with 302 additions and 344 deletions

View File

@@ -1,27 +1,21 @@
package org.maxkey.autoconfigure;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.oas.annotations.EnableOpenApi;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
@Configuration
@EnableSwagger2
@EnableOpenApi
@EnableKnife4j
public class SwaggerConfig {
final static Logger _logger = LoggerFactory.getLogger(SwaggerConfig.class);
@Value("${maxkey.swagger.title}")
String title;
@@ -35,38 +29,45 @@ public class SwaggerConfig {
boolean enable;
@Bean
public Docket docket(){
if(enable) {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("org.maxkey")
.and(RequestHandlerSelectors.withClassAnnotation(Api.class))
.and(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)))
.paths(PathSelectors.any())
.build();
}else {
return null;
}
public GroupedOpenApi userApi(){
String[] paths = {
"/login",
"/logout",
"/login/**",
"/logout/**",
"/authz/**",
"/authz/**/**",
"/metadata/saml20/**" ,
"/onlineticket/validate/**",
"/api/connect/v10/userinfo",
"/api/oauth/v20/me"
};
String[] packagedToMatch = { "org.maxkey.authz" };
return GroupedOpenApi.builder().group(title)
.pathsToMatch(paths)
.packagesToScan(packagedToMatch).build();
}
// 配置swagger信息
@SuppressWarnings(value = { })
private ApiInfo apiInfo() {
Contact contact = new Contact(
"MaxKey.top",
"https://www.maxkey.top/",
"maxkeysupport@163.com");
return new ApiInfo(
title,
description,
version,
"https://www.maxkey.top/",
contact,
"Apache License, Version 2.0",
"http://www.apache.org/licenses/LICENSE-2.0",
new ArrayList<>());
}
@Bean
public OpenAPI docOpenAPI() {
return new OpenAPI()
.info(
new Info()
.title(title)
.description(description)
.version(version)
.termsOfService("https://www.maxkey.top/")
.license(
new License()
.name("Apache License, Version 2.0")
.url("http://www.apache.org/licenses/LICENSE-2.0")
)
).
externalDocs(
new ExternalDocumentation()
.description("MaxKey.top contact maxkeysupport@163.com")
.url("https://www.maxkey.top/")
);
}
}

View File

@@ -69,22 +69,24 @@ public class GroupMember extends UserInfo implements Serializable{
* @param memberId
* @param type
*/
public GroupMember(String groupId, String memberId, String type) {
public GroupMember(String groupId, String memberId, String type , String instId) {
super();
this.groupId = groupId;
this.memberId = memberId;
this.type = type;
this.instId = instId;
}
public GroupMember(String groupId, String groupName, String memberId,
String memberName, String type) {
String memberName, String type , String instId) {
super();
this.groupId = groupId;
this.groupName = groupName;
this.memberId = memberId;
this.memberName = memberName;
this.type = type;
this.instId = instId;
}

View File

@@ -66,10 +66,11 @@ public class GroupPrivileges extends Apps implements Serializable{
* @param groupId
* @param appId
*/
public GroupPrivileges(String groupId, String appId) {
public GroupPrivileges(String groupId, String appId, String instId) {
super();
this.groupId = groupId;
this.appId = appId;
this.instId = instId;
}

View File

@@ -120,21 +120,23 @@ public class RoleMember extends UserInfo implements Serializable {
this.instName = instName;
}
public RoleMember(String roleId, String memberId, String type) {
public RoleMember(String roleId, String memberId, String type , String instId) {
super();
this.roleId = roleId;
this.memberId = memberId;
this.type = type;
this.instId = instId;
}
public RoleMember(String roleId, String roleName, String memberId, String memberName, String type) {
public RoleMember(String roleId, String roleName, String memberId, String memberName, String type ,String instId) {
super();
this.roleId = roleId;
this.roleName = roleName;
this.memberId = memberId;
this.memberName = memberName;
this.type = type;
this.instId = instId;
}
@Override

View File

@@ -53,9 +53,10 @@ public class RolePermissions extends JpaBaseEntity implements Serializable {
public RolePermissions() {
}
public RolePermissions(String appId, String roleId) {
public RolePermissions(String appId, String roleId, String instId) {
this.appId = appId;
this.roleId = roleId;
this.instId = instId;
}
/**
@@ -64,11 +65,12 @@ public class RolePermissions extends JpaBaseEntity implements Serializable {
* @param roleId String
* @param resourceId String
*/
public RolePermissions(String appId, String roleId, String resourceId) {
public RolePermissions(String appId, String roleId, String resourceId , String instId) {
this.id = WebContext.genId();
this.appId = appId;
this.roleId = roleId;
this.resourceId = resourceId;
this.instId = instId;
}
public String getId() {