-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
44 changed files
with
2,220 additions
and
690 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.12" | ||
mkdocs: | ||
configuration: mkdocs.yml | ||
python: | ||
install: | ||
- requirements: docs/requirements.txt |
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,36 +1,38 @@ | ||
mysql56: | ||
image: mysql:5.6 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MYSQL_USER=springuser | ||
- MYSQL_PASSWORD=ThePassword | ||
- MYSQL_DATABASE=db_example | ||
- MYSQL_RANDOM_ROOT_PASSWORD=true | ||
mysql57: | ||
image: mysql:5.7 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MYSQL_USER=springuser | ||
- MYSQL_PASSWORD=ThePassword | ||
- MYSQL_DATABASE=db_example | ||
- MYSQL_RANDOM_ROOT_PASSWORD=true | ||
mysql: | ||
image: mysql:8.0 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MYSQL_USER=springuser | ||
- MYSQL_PASSWORD=ThePassword | ||
- MYSQL_DATABASE=db_example | ||
- MYSQL_RANDOM_ROOT_PASSWORD=true | ||
mariadb: | ||
image: mariadb:10.6 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MARIADB_USER=springuser | ||
- MARIADB_PASSWORD=ThePassword | ||
- MARIADB_DATABASE=db_example | ||
- MARIADB_RANDOM_ROOT_PASSWORD=true | ||
version: "3.8" | ||
services: | ||
mysql56: | ||
image: mysql:5.6 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MYSQL_USER=springuser | ||
- MYSQL_PASSWORD=ThePassword | ||
- MYSQL_DATABASE=db_example | ||
- MYSQL_RANDOM_ROOT_PASSWORD=true | ||
mysql57: | ||
image: mysql:5.7 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MYSQL_USER=springuser | ||
- MYSQL_PASSWORD=ThePassword | ||
- MYSQL_DATABASE=db_example | ||
- MYSQL_RANDOM_ROOT_PASSWORD=true | ||
mysql: | ||
image: mysql:8.0 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MYSQL_USER=springuser | ||
- MYSQL_PASSWORD=ThePassword | ||
- MYSQL_DATABASE=db_example | ||
- MYSQL_RANDOM_ROOT_PASSWORD=true | ||
mariadb: | ||
image: mariadb:10.6 | ||
ports: | ||
- "3306:3306" | ||
environment: | ||
- MARIADB_USER=springuser | ||
- MARIADB_PASSWORD=ThePassword | ||
- MARIADB_DATABASE=db_example | ||
- MARIADB_RANDOM_ROOT_PASSWORD=true |
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 |
---|---|---|
|
@@ -14,5 +14,5 @@ plugins: | |
markdown_extensions: | ||
- admonition | ||
extra: | ||
rdp_version: 1.5.5 | ||
rdp_version: 1.5.8 | ||
git_ref: master |
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,75 @@ | ||
package ubc.pavlab.rdp; | ||
|
||
import lombok.extern.apachecommons.CommonsLog; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.convert.DurationUnit; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.http.converter.FormHttpMessageConverter; | ||
import org.springframework.web.client.RestTemplate; | ||
import ubc.pavlab.rdp.validation.*; | ||
|
||
import java.io.IOException; | ||
import java.time.Duration; | ||
import java.time.temporal.ChronoUnit; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
/** | ||
* This configuration provides a few {@link org.springframework.validation.Validator} beans. | ||
*/ | ||
@CommonsLog | ||
@Configuration | ||
public class ValidationConfig { | ||
|
||
@Bean | ||
public EmailValidator emailValidator( | ||
@Value("${rdp.settings.allowed-email-domains}") List<String> allowedEmailDomains, | ||
@Value("${rdp.settings.allowed-email-domains-file}") Resource allowedEmailDomainsFile, | ||
@Value("${rdp.settings.allowed-email-domains-file-refresh-delay}") @DurationUnit(ChronoUnit.SECONDS) Duration refreshDelay, | ||
@Value("${rdp.settings.allow-internationalized-email-domains}") boolean allowIdn ) throws IOException { | ||
List<AllowedDomainStrategy> strategies = new ArrayList<>(); | ||
if ( allowedEmailDomains != null && !allowedEmailDomains.isEmpty() ) { | ||
SetBasedAllowedDomainStrategy strategy = new SetBasedAllowedDomainStrategy( allowedEmailDomains ); | ||
strategies.add( strategy ); | ||
log.info( String.format( "Email validation is configured to accept addresses from: %s.", String.join( ", ", | ||
strategy.getAllowedDomains() ) ) ); | ||
} | ||
if ( allowedEmailDomainsFile != null ) { | ||
log.info( "Reading allowed email domains from " + allowedEmailDomainsFile + "..." ); | ||
if ( refreshDelay.isZero() ) { | ||
log.warn( "The refresh delay for reading " + allowedEmailDomainsFile + " is set to zero: the file will be re-read for every email domain validation." ); | ||
} | ||
ResourceBasedAllowedDomainStrategy strategy = new ResourceBasedAllowedDomainStrategy( allowedEmailDomainsFile, refreshDelay ); | ||
strategy.refresh(); | ||
Set<String> allowedDomains = strategy.getAllowedDomains(); | ||
strategies.add( strategy ); | ||
if ( strategy.getAllowedDomains().size() <= 5 ) { | ||
log.info( String.format( "Email validation is configured to accept addresses from: %s.", String.join( ", ", allowedDomains ) ) ); | ||
} else { | ||
log.info( String.format( "Email validation is configured to accept addresses from a list of %d domains.", allowedDomains.size() ) ); | ||
} | ||
} | ||
AllowedDomainStrategy strategy; | ||
if ( strategies.isEmpty() ) { | ||
strategy = ( domain ) -> true; | ||
log.warn( "No allowed email domains file specified, all domains will be allowed for newly registered users." ); | ||
} else if ( strategies.size() == 1 ) { | ||
strategy = strategies.iterator().next(); | ||
} else { | ||
strategy = domain -> strategies.stream().anyMatch( s -> s.allows( domain ) ); | ||
} | ||
return new EmailValidator( strategy, allowIdn ); | ||
} | ||
|
||
@Bean | ||
@ConditionalOnProperty("rdp.site.recaptcha-secret") | ||
public RecaptchaValidator recaptchaValidator( @Value("${rdp.site.recaptcha-secret}") String secret ) { | ||
RestTemplate rt = new RestTemplate(); | ||
rt.getMessageConverters().add( new FormHttpMessageConverter() ); | ||
return new RecaptchaValidator( rt, secret ); | ||
} | ||
} |
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
Oops, something went wrong.