Skip to content

Commit c618cab

Browse files
authored
Merge branch 'main' into idp-1624
2 parents 982d868 + 5303a9b commit c618cab

4 files changed

Lines changed: 27 additions & 39 deletions

File tree

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/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)