-
-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/commjoen/wrongsecrets into …
…#44-JavaScript_library_with_key_obfuscated � Conflicts: � pom.xml
- Loading branch information
Showing
13 changed files
with
195 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
terraform { | ||
required_providers { | ||
aws = { | ||
version = "~> 4.0" | ||
} | ||
} | ||
} | ||
|
||
variable "region" { | ||
description = "The AWS region to use" | ||
type = string | ||
default = "eu-west-1" | ||
} | ||
|
||
provider "aws" { | ||
region = var.region | ||
} | ||
|
||
resource "aws_s3_bucket" "state" {} | ||
|
||
resource "aws_s3_bucket_server_side_encryption_configuration" "encryption" { | ||
bucket = aws_s3_bucket.state.id | ||
rule { | ||
apply_server_side_encryption_by_default { | ||
sse_algorithm = "AES256" | ||
} | ||
} | ||
} | ||
|
||
output "s3_bucket_name" { | ||
description = "Name of the terraform state bucket" | ||
value = aws_s3_bucket.state.id | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 6 additions & 7 deletions
13
src/main/java/org/owasp/wrongsecrets/HerokuWebSecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,19 @@ | ||
package org.owasp.wrongsecrets; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
|
||
@Configuration | ||
@Order(1) | ||
public class HerokuWebSecurityConfig extends WebSecurityConfigurerAdapter { | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.requiresChannel() | ||
.requestMatchers(r -> r.getHeader("X-Forwarded-Proto") != null) | ||
.requiresSecure() | ||
.and() | ||
.httpBasic().disable(); | ||
http.requestMatcher(r -> r.getRequestURI().contains("canaries/tokencallback")) | ||
.csrf().disable(); | ||
} | ||
.requestMatchers(r -> r.getHeader("x-forwarded-proto") != null || r.getHeader("X-Forwarded-Proto") != null) | ||
.requiresSecure(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/owasp/wrongsecrets/canaries/TokenCallbackSecurityConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.owasp.wrongsecrets.canaries; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; | ||
|
||
@Configuration | ||
@Order(0) | ||
public class TokenCallbackSecurityConfiguration extends WebSecurityConfigurerAdapter { | ||
|
||
@Override | ||
protected void configure(HttpSecurity http) throws Exception { | ||
http.requestMatcher(r -> r.getRequestURL().toString().contains("canaries")).csrf().disable(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/test/java/org/owasp/wrongsecrets/HerokuWebSecurityConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.owasp.wrongsecrets; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.web.client.RestTemplateBuilder; | ||
import org.springframework.boot.web.server.LocalServerPort; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.client.ResourceAccessException; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
public class HerokuWebSecurityConfigTest { | ||
|
||
@LocalServerPort | ||
private int port; | ||
|
||
@Autowired | ||
private RestTemplateBuilder builder; | ||
|
||
@Test | ||
void shouldRedirectwhenProtoProvided() { | ||
try { | ||
var restTemplate = builder | ||
.defaultHeader("x-forwarded-proto", "value") | ||
.build(); | ||
var rootAddress = "http://localhost:" + port + "/"; | ||
restTemplate.getForEntity(rootAddress, String.class); | ||
fail(); | ||
} catch (ResourceAccessException e) { | ||
assert (e.getCause().getCause().toString()).contains("Redirect"); | ||
} | ||
} | ||
|
||
@Test | ||
void shouldNotRedirectwhenProtoNotProvided() { | ||
var restTemplate = builder | ||
.build(); | ||
var rootAddress = "http://localhost:" + port + "/"; | ||
ResponseEntity entity = restTemplate.getForEntity(rootAddress, String.class); | ||
assertTrue(entity.getStatusCode().is2xxSuccessful()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters