🔖 发布一个版本。 v1.4.0 新增代码生成

This commit is contained in:
冷冷 committed 2018-08-02 22:35:56 +08:00
1 parent cbceb44fb4
commit 3a80957f29
7 files changed
+91 -5

No files matched your search

@@ -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 {
@@ -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);
}
}