mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-11 05:19:00 +08:00
🔖 发布一个版本。 v1.4.0 新增代码生成
This commit is contained in:
1 parent
cbceb44fb4
commit
3a80957f29
7 files changed
+91
-5
No files matched your search
+2
-2
@@ -11,7 +11,7 @@
|
||||
Target Server Version : 50722
|
||||
File Encoding : utf-8
|
||||
|
||||
Date: 08/02/2018 22:07:34 PM
|
||||
Date: 08/02/2018 22:34:32 PM
|
||||
*/
|
||||
|
||||
SET NAMES utf8;
|
||||
@@ -163,7 +163,7 @@ CREATE TABLE `sys_oauth_client_details` (
|
||||
-- Records of `sys_oauth_client_details`
|
||||
-- ----------------------------
|
||||
BEGIN;
|
||||
INSERT INTO `sys_oauth_client_details` VALUES ('app', null, 'app', 'server', 'password,refresh_token', null, null, null, null, null, 'true'), ('pig', null, 'pig', 'server', 'password,refresh_token', null, null, null, null, null, 'true'), ('test', null, 'test', 'server', 'password,refresh_token', null, null, null, null, null, 'true');
|
||||
INSERT INTO `sys_oauth_client_details` VALUES ('app', null, 'app', 'server', 'password,refresh_token', null, null, null, null, null, 'true'), ('gen', null, 'gen', 'server', 'password,refresh_token', null, null, null, null, null, 'true'), ('pig', null, 'pig', 'server', 'password,refresh_token', null, null, null, null, null, 'true'), ('test', null, 'test', 'server', 'password,refresh_token', null, null, null, null, null, 'true');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
||||
@@ -88,4 +88,10 @@ swagger:
|
||||
- scope: 'server'
|
||||
description: 'server all'
|
||||
token-url-list:
|
||||
- 'http://localhost:9999/auth/oauth/token'
|
||||
- ${security.oauth2.resource.token-info-uri}
|
||||
|
||||
## spring security 配置
|
||||
security:
|
||||
oauth2:
|
||||
resource:
|
||||
token-info-uri: http://localhost:9999/auth/oauth/check_token
|
||||
@@ -1,3 +1,11 @@
|
||||
## spring security 配置
|
||||
security:
|
||||
oauth2:
|
||||
client:
|
||||
client-id: gen
|
||||
client-secret: gen
|
||||
scope: server
|
||||
|
||||
# 数据源配置
|
||||
spring:
|
||||
datasource:
|
||||
|
||||
@@ -5,8 +5,6 @@ security:
|
||||
client-id: pig
|
||||
client-secret: pig
|
||||
scope: server
|
||||
resource:
|
||||
token-info-uri: http://localhost:9999/auth/oauth/check_token
|
||||
|
||||
# 数据源
|
||||
spring:
|
||||
|
||||
@@ -45,6 +45,16 @@
|
||||
<artifactId>pigx-common-core</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.pig4cloud</groupId>
|
||||
<artifactId>pigx-common-swagger</artifactId>
|
||||
<version>${pigx.version}</version>
|
||||
</dependency>
|
||||
<!--spring security 、oauth、jwt依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-security</artifactId>
|
||||
</dependency>
|
||||
<!--代码生成模板引擎-->
|
||||
<dependency>
|
||||
<artifactId>velocity</artifactId>
|
||||
|
||||
+2
@@ -17,6 +17,7 @@
|
||||
|
||||
package com.pig4cloud.pigx.codegen;
|
||||
|
||||
import com.pig4cloud.pigx.common.swagger.annotation.EnablePigxSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.cloud.client.SpringCloudApplication;
|
||||
|
||||
@@ -25,6 +26,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
|
||||
* @date 2018/07/29
|
||||
* 代码生成模块
|
||||
*/
|
||||
@EnablePigxSwagger2
|
||||
@SpringCloudApplication
|
||||
public class PigxCodeGenApplication {
|
||||
|
||||
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2025, lengleng All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the pig4cloud.com developer nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
* Author: lengleng (wangiegie@gmail.com)
|
||||
*/
|
||||
|
||||
package com.pig4cloud.pigx.codegen.config;
|
||||
|
||||
import com.pig4cloud.pigx.common.security.component.PigAccessDeniedHandler;
|
||||
import com.pig4cloud.pigx.common.security.component.ResourceAuthExceptionEntryPoint;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;
|
||||
import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2018/6/22
|
||||
*/
|
||||
@Configuration
|
||||
@EnableResourceServer
|
||||
@AllArgsConstructor
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
|
||||
private final PigAccessDeniedHandler pigAccessDeniedHandler;
|
||||
private final ResourceAuthExceptionEntryPoint resourceAuthExceptionEntryPoint;
|
||||
|
||||
@Override
|
||||
public void configure(HttpSecurity http) throws Exception {
|
||||
http.authorizeRequests()
|
||||
.antMatchers("/actuator/**", "/v2/api-docs").permitAll()
|
||||
.anyRequest().authenticated()
|
||||
.and().csrf().disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* why add resourceId
|
||||
* https://stackoverflow.com/questions/28703847/how-do-you-set-a-resource-id-for-a-token
|
||||
*
|
||||
* @param resources
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
|
||||
resources.authenticationEntryPoint(resourceAuthExceptionEntryPoint)
|
||||
.accessDeniedHandler(pigAccessDeniedHandler);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user