Skip to content
This repository has been archived by the owner on Oct 26, 2022. It is now read-only.

VGS integration with Spring framework

License

Notifications You must be signed in to change notification settings

verygoodsecurity/vgs-proxy-spring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

VGS Logo

vgs-proxy-spring
Provides an easy way to integrate a Spring-based project with the VGS forward proxy.

CircleCI

Quick Start

Installation

Before you begin, add this library as a dependency to your project.

For Maven:

<dependency>
    <groupId>com.verygoodsecurity</groupId>
    <artifactId>vgs-proxy-spring</artifactId>
    <version>1.0.0</version>
</dependency>

For Gradle:

compile 'com.verygoodsecurity:vgs-proxy-spring:1.0.0'

Usage

First of all, set the vgs.proxy.url property in the application context for the vault you want to integrate with. Look for the Outbound Route URL on the Integration tab within the dashboard and replace the placeholders with a pair of access credentials. The resulting URL should look similar to this one:

https://USvWJyqzunxnW1pDKxgvPLmf:3da78204-e566-4e03-a03a-d84e3d1d4d1b@tntabeiyol.SANDBOX.verygoodproxy.com:8080

Secondly, do the following steps to configure a RestTemplate to use the VGS forward proxy:

  • Declare a bean annotated with @VgsProxied
  • Annotate any configuration class with @EnableVgsProxy

Here's an example configuration you may end up with:

@Configuration
@EnableVgsProxy
public class AppConfig {

    @Bean
    @VgsProxied
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}

Of course, not every HTTP request should be proxied, so you may also have a RestTemplate that is not configured to use the proxy. Simply declare another bean and inject it as normal:

@Configuration
@EnableVgsProxy
public class AppConfig {

    @Bean
    @VgsProxied
    public RestTemplate vgsProxied() {
        return new RestTemplate();
    }

    @Bean
    @Primary
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }
}

However, you must use a qualifier to access the proxied RestTemplate then:

@Component
public class MySecureClient {

  private final RestTemplate restTemplate;
  private final RestTemplate vgsProxied;

  @Autowired
  public MySecureClient(RestTemplate restTemplate,
                        @VgsProxied RestTemplate vgsProxied) {

    this.restTemplate = restTemplate;
    this.vgsProxied = vgsProxied;
  }

  public void doRegularStuff() {
    return restTemplate.getForObject("https://httpbin.verygoodsecurity.io/get", String.class);
  }

  public void doSecureStuff(String json) {
    vgsProxied.postForObject("https://httpbin.verygoodsecurity.io/post", json, String.class);
  }
}

For a complete example, see the sample project.

What is VGS?

Want to just jump right in? Check out our getting started guide.

Very Good Security (VGS) allows you to enhance your security standing while maintaining the utility of your data internally and with third-parties. As an added benefit, we accelerate your compliance certification process and help you quickly obtain security-related compliances that stand between you and your market opportunities.

To learn more, visit us at https://www.verygoodsecurity.com/

License

This project is licensed under the MIT license. See the LICENSE file for details.

About

VGS integration with Spring framework

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages