Skip to content

Commit 6276ac7

Browse files
authored
Merge branch 'main' into IDP-2165
2 parents a61ab79 + ac368b2 commit 6276ac7

7 files changed

Lines changed: 36 additions & 48 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,11 @@ SilAuth will rate limit failed logins by username and by every untrusted IP
616616
address from a login attempt.
617617

618618
##### tl;dr ("the short version")
619-
If there have been more than 10 failed logins for a given username (or IP
619+
If there have been more than 5 failed logins for a given username (or IP
620620
address) within the past hour, a captcha will be included in the webpage. The
621621
user may or may not have to directly interact with the captcha, though.
622622

623-
If there have been more than 50 failed logins for that username (or IP address)
623+
If there have been more than 20 failed logins for that username (or IP address)
624624
within the past hour, logins for that username (or IP address) will be blocked
625625
for up to an hour.
626626

@@ -646,10 +646,10 @@ also actual tests that are run to ensure those descriptions are correct.
646646

647647
##### Example 1
648648

649-
- If `BLOCK_AFTER_NTH_FAILED_LOGIN` is 50, and
650-
- if `REQUIRE_CAPTCHA_AFTER_NTH_FAILED_LOGIN` is 10, and
649+
- If `BLOCK_AFTER_NTH_FAILED_LOGIN` is 20, and
650+
- if `REQUIRE_CAPTCHA_AFTER_NTH_FAILED_LOGIN` is 5, and
651651
- if there have been 4 failed login attempts for `john_smith`, and
652-
- there have been 10 failed login attempts from `11.22.33.44`, and
652+
- there have been 5 failed login attempts from `11.22.33.44`, and
653653
- there have been 3 failed login attempts from `192.168.1.2`, and
654654
- someone tries to login as `john_smith` from `192.168.1.2` and their request
655655
goes through a proxy at `11.22.33.44`, then
@@ -658,7 +658,7 @@ also actual tests that are run to ensure those descriptions are correct.
658658
##### Example 2
659659

660660
- However, if all of the above is true, but
661-
- there have now been 55 failed login attempts from `11.22.33.44`, then
661+
- there have now been 25 failed login attempts from `11.22.33.44`, then
662662
- any request involving that IP address will be blocked for 25 seconds after
663663
the most recent of those failed logins.
664664

composer.lock

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/editing_authprocs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ Logs information (common name, eduPrincipalPersonalName, employee number, IdP, S
4040
The following config is not needed on AWS, but it is needed locally
4141
'DynamoEndpoint' ex. http://dynamo:8000
4242

43-
Ensure the DYNAMO_ACCESS_KEY_ID and DYNAMO_SECRET_ACCESS_KEY environment variables are set as shown in the local.env.dist file.
43+
Ensure the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables are set as shown in the local.env.dist file.

local.env.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,10 @@ ENV_ID=
9999
# A valid format for 'baseurlpath' is: [(http|https)://(hostname|fqdn)[:port]]/[path/to/simplesaml/]
100100
BASE_URL_PATH=
101101

102-
# DYNAMO_ACCESS_KEY_ID and DYNAMO_SECRET_ACCESS_KEY can be set to AWS IAM credentials with access
102+
# AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY can be set to AWS IAM credentials with access
103103
# to a DynamoDB table for storage of user access logs. For more information see docs/editing_authprocs.md
104-
DYNAMO_ACCESS_KEY_ID
105-
DYNAMO_SECRET_ACCESS_KEY
104+
AWS_ACCESS_KEY_ID
105+
AWS_SECRET_ACCESS_KEY
106106

107107
# HELP_CENTER_URL can be set to a URL for an end-user support site. If provided, it will be used for a
108108
# link address on the IdP selection page (selectidp-links) and the IdP login page (loginuserpass).

modules/material/themes/material/silauth/loginuserpass.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@
168168
<button
169169
type="button"
170170
onclick="forgotPassword()"
171-
class="mdl-button mdl-button--colored mdl-typography--caption"
171+
class="mdl-button mdl-button--colored mdl-typography--raised"
172172
>
173173
{{ '{login:forgot}'|trans }}
174174
</button>

modules/silauth/src/Auth/Source/auth/Authenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818
class Authenticator
1919
{
20-
const REQUIRE_CAPTCHA_AFTER_NTH_FAILED_LOGIN = 10;
21-
const BLOCK_AFTER_NTH_FAILED_LOGIN = 50;
20+
const REQUIRE_CAPTCHA_AFTER_NTH_FAILED_LOGIN = 5;
21+
const BLOCK_AFTER_NTH_FAILED_LOGIN = 20;
2222
const MAX_SECONDS_TO_BLOCK = 3600; // 3600 seconds = 1 hour
2323

2424
private ?AuthError $authError = null;

modules/sildisco/src/Auth/Process/LogUser.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Aws\DynamoDb\Marshaler;
66
use Aws\Sdk;
77
use Exception;
8+
use Sil\PhpEnv\Env;
89
use SimpleSAML\Auth\ProcessingFilter;
910
use SimpleSAML\Error\MetadataNotFound;
1011
use SimpleSAML\Logger;
@@ -23,12 +24,6 @@
2324
*/
2425
class LogUser extends ProcessingFilter
2526
{
26-
27-
const AWS_ACCESS_KEY_ID_ENV = "DYNAMO_ACCESS_KEY_ID";
28-
29-
const AWS_SECRET_ACCESS_KEY_ENV = "DYNAMO_SECRET_ACCESS_KEY";
30-
31-
3227
const IDP_KEY = "saml:sp:IdP"; // the key that points to the entity id in the state
3328

3429
// the metadata key for the IDP's Namespace code (i.e. short name)
@@ -78,17 +73,6 @@ public function process(array &$state): void
7873
return;
7974
}
8075

81-
$awsKey = getenv(self::AWS_ACCESS_KEY_ID_ENV);
82-
if (!$awsKey) {
83-
Logger::error(self::AWS_ACCESS_KEY_ID_ENV . " environment variable is required for LogUser.");
84-
return;
85-
}
86-
$awsSecret = getenv(self::AWS_SECRET_ACCESS_KEY_ENV);
87-
if (!$awsSecret) {
88-
Logger::error(self::AWS_SECRET_ACCESS_KEY_ENV . " environment variable is required for LogUser.");
89-
return;
90-
}
91-
9276
assert(is_array($state));
9377

9478
// Get the SP's entity id
@@ -99,12 +83,16 @@ public function process(array &$state): void
9983

10084
$sdkConfig = [
10185
'region' => $this->dynamoRegion,
102-
'version' => 'latest',
103-
'credentials' => [
86+
];
87+
88+
$awsKey = Env::getString('AWS_ACCESS_KEY_ID', Env::getString('DYNAMO_ACCESS_KEY_ID'));
89+
$awsSecret = Env::getString('AWS_SECRET_ACCESS_KEY', Env::getString('DYNAMO_SECRET_ACCESS_KEY'));
90+
if (!empty($awsSecret) && !empty($awsKey)) {
91+
$sdkConfig['credentials'] = [
10492
'key' => $awsKey,
10593
'secret' => $awsSecret,
106-
],
107-
];
94+
];
95+
}
10896

10997
if (!empty($this->dynamoEndpoint)) {
11098
$sdkConfig['endpoint'] = $this->dynamoEndpoint;

0 commit comments

Comments
 (0)