1 Star 0 Fork 0

ArcherTrister / micro-service

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
根项目 子项目 端口号 描述
hello-apache-dubbo
hello-apache-dubbo hello-apache-dubbo-dependencies
hello-apache-dubbo hello-apache-dubbo-consumer 8040
hello-apache-dubbo hello-apache-dubbo-provider
hello-apache-dubbo-provider hello-apache-dubbo-provider-api
hello-apache-dubbo-provider hello-apache-dubbo-provider-service 20881
hello-spring-boot 8030
hello-spring-cloud-alibaba
hello-spring-cloud-alibaba hello-spring-cloud-alibaba-dependencies
hello-spring-cloud-alibaba hello-spring-cloud-alibaba-consumer 8080
hello-spring-cloud-alibaba hello-spring-cloud-alibaba-provider 8070
hello-spring-security-oauth2
hello-spring-security-oauth2 hello-spring-security-oauth2-core
hello-spring-security-oauth2 hello-spring-security-oauth2-dependencies
hello-spring-security-oauth2 hello-spring-security-oauth2-resource 8020
hello-spring-security-oauth2 hello-spring-security-oauth2-server 8010
micro-service
micro-service micro-service-dependencies
micro-service micro-service-core
micro-service micro-service-business
micro-service-business micro-service-business-auth-center 9001
micro-service-business micro-service-business-user-center 9000
micro-service micro-service-provider
micro-service-provider micro-service-provider-dubbo-base-client
micro-service-provider micro-service-provider-dubbo-base-server 21881
micro-service-provider micro-service-provider-feign-base-client
micro-service-provider micro-service-provider-feign-base-server 9002

设置注释模板

File-->Settings-->Editor-->File and Code Templates-->includes

/**
 * @author :ArcherTrister
 * @date :Created in ${DATE} ${TIME}
 * @description :${description}
 * @modified By :
 * @version : $version
 */

设置包引入

Code Style-->Java-->imports-->Class count xxxx 999

插件

md教程

教程

git教程

git rm -r --cached .
git add .
git commit -m "update .gitignore"
import com.fasterxml.jackson.annotation.JsonIgnore;
@JsonIgnore
https://github.com/spring-projects/spring-security-oauth/blob/master/spring-security-oauth2/src/test/resources/schema.sql
git clone https://github.com/fp2952/spring-boot-security-demo.git
git clone https://github.com/victorzhgx/oauth2.git

资源配置

package com.aak.configuration;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
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;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;

import javax.sql.DataSource;

/**
 * @author :ArcherTrister
 * @date :Created in 2020/2/26 14:35
 * @description:资源配置
 * @modified By:
 * @version: 1.0.0
 */
@EnableResourceServer
@Configuration
public class ResourcesServerConfiguration  extends ResourceServerConfigurerAdapter {

    @Bean
    @ConfigurationProperties(prefix="spring.datasource")
    public DataSource ouathDataSource(){return DataSourceBuilder.create().build();}

    @Override
    public void configure(ResourceServerSecurityConfigurer resources)throws Exception{

        TokenStore tokenStore=new JdbcTokenStore(ouathDataSource());
        resources.resourceId("product_api").tokenStore(tokenStore);

    }

//    @Override
//    public void configure(ResourceServerSecurityConfigurer resources) throws Exception {
//        super.configure(resources);
//        resources.resourceId(oAuth2ClientProperties.getClientId());
//        if (Objects.nonNull(remoteTokenServices)) {
//            resources.tokenServices(remoteTokenServices);
//        }
//    }

    @Override
    public void configure(HttpSecurity http) throws Exception{
        http
                .authorizeRequests()
                .antMatchers(HttpMethod.GET, "/**").access("#oauth2.hasScope('read')")
                .antMatchers(HttpMethod.POST, "/**").access("#oauth2.hasScope('write')")
                .antMatchers(HttpMethod.PATCH, "/**").access("#oauth2.hasScope('write')")
                .antMatchers(HttpMethod.PUT, "/**").access("#oauth2.hasScope('write')")
                .antMatchers(HttpMethod.DELETE, "/**").access("#oauth2.hasScope('write')")
                .and()

                .headers().addHeaderWriter((request, response) -> {
            response.addHeader("Access-Control-Allow-Origin", "*");
            if (request.getMethod().equals("OPTIONS")) {
                response.setHeader("Access-Control-Allow-Methods", request.getHeader("Access-Control-Request-Method"));
                response.setHeader("Access-Control-Allow-Headers", request.getHeader("Access-Control-Request-Headers"));
            }
        });
    }
}

空文件

简介

spring cloud alibaba 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/archertrister/micro-service.git
git@gitee.com:archertrister/micro-service.git
archertrister
micro-service
micro-service
master

搜索帮助