Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.demo
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ KEYCLOAK_MANAGEMENT_CLIENT_ID=adminClient
KEYCLOAK_MANAGEMENT_CLIENT_SECRET=
KEYCLOAK_REALM=credebl-platform

SCHEMA_FILE_SERVER_URL='https://schema.credebl.id/schemas/'
SCHEMA_FILE_SERVER_URL=
SCHEMA_FILE_SERVER_TOKEN=

GEO_LOCATION_MASTER_DATA_IMPORT_SCRIPT=/prisma/scripts/geo_location_data_import.sh
Expand Down
18 changes: 11 additions & 7 deletions apps/agent-provisioning/AFJ/scripts/docker_start_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ PROTOCOL=${12}
TENANT=${13}
AFJ_VERSION=${14}
INDY_LEDGER=${15}
INBOUND_ENDPOINT=${16}
SCHEMA_FILE_SERVER_URL=${17}
AGENT_API_KEY=${18}
ADMIN_PORT_FILE="$PWD/agent-provisioning/AFJ/port-file/last-admin-port.txt"
INBOUND_PORT_FILE="$PWD/agent-provisioning/AFJ/port-file/last-inbound-port.txt"
ADMIN_PORT=8001
INBOUND_PORT=9001

echo "AGENCY: $AGENCY"
echo "EXTERNAL_IP: $EXTERNAL_IP"
Expand All @@ -34,11 +41,6 @@ echo "TENANT: $TENANT"
echo "AFJ_VERSION: $AFJ_VERSION"
echo "INDY_LEDGER: $INDY_LEDGER"

ADMIN_PORT_FILE="$PWD/agent-provisioning/AFJ/port-file/last-admin-port.txt"
INBOUND_PORT_FILE="$PWD/agent-provisioning/AFJ/port-file/last-inbound-port.txt"
ADMIN_PORT=8001
INBOUND_PORT=9001

increment_port() {
local port="$1"
local lower_limit="$2"
Expand Down Expand Up @@ -144,7 +146,9 @@ cat <<EOF >${CONFIG_FILE}
],
"webhookUrl": "$WEBHOOK_HOST/wh/$AGENCY",
"adminPort": $ADMIN_PORT,
"tenancy": $TENANT
"tenancy": $TENANT,
"schemaFileServerURL": "$SCHEMA_FILE_SERVER_URL",
"apiKey": "$AGENT_API_KEY"
}
EOF

Expand Down Expand Up @@ -225,7 +229,7 @@ if [ $? -eq 0 ]; then
container_logs=$(docker logs $(docker ps -q --filter "name=${AGENCY}_${CONTAINER_NAME}"))

# Extract the token from the logs using sed
token=$(echo "$container_logs" | sed -nE 's/.*API Token: ([^ ]+).*/\1/p')
token=$(echo "$container_logs" | sed -nE 's/.*** API Key: ([^ ]+).*/\1/p')

# Print the extracted token
echo "Token: $token"
Expand Down
2 changes: 1 addition & 1 deletion apps/agent-provisioning/AFJ/scripts/start_agent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ AFJ_VERSION=${14}
INDY_LEDGER=${15}
INBOUND_ENDPOINT=${16}
SCHEMA_FILE_SERVER_URL=${17}
AGENT_API_KEY="${18}"
AGENT_API_KEY=${18}
ADMIN_PORT_FILE="$PWD/apps/agent-provisioning/AFJ/port-file/last-admin-port.txt"
INBOUND_PORT_FILE="$PWD/apps/agent-provisioning/AFJ/port-file/last-inbound-port.txt"
ADMIN_PORT=8001
Expand Down
27 changes: 12 additions & 15 deletions apps/agent-provisioning/AFJ/scripts/start_agent_ecs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ AFJ_VERSION=${14}
INDY_LEDGER=${15}
INBOUND_ENDPOINT=${16}
SCHEMA_FILE_SERVER_URL=${17}
AGENT_HOST=${18}
AWS_ACCOUNT_ID=${19}
S3_BUCKET_ARN=${20}
CLUSTER_NAME=${21}
TESKDEFINITION_FAMILY=${22}
AGENT_API_KEY=${18}
AGENT_HOST=${19}
AWS_ACCOUNT_ID=${20}
S3_BUCKET_ARN=${21}
CLUSTER_NAME=${22}
TASKDEFINITION_FAMILY=${23}

DESIRED_COUNT=1

Expand All @@ -37,7 +38,7 @@ random_string=$(generate_random_string)
# Print the generated random string
echo "Random String: $random_string"

SERVICE_NAME="${CONTAINER_NAME}-service-test"
SERVICE_NAME="${CONTAINER_NAME}-service"
EXTERNAL_IP=$(echo "$2" | tr -d '[:space:]')
ADMIN_PORT_FILE="$PWD/agent-provisioning/AFJ/port-file/last-admin-port.txt"
INBOUND_PORT_FILE="$PWD/agent-provisioning/AFJ/port-file/last-inbound-port.txt"
Expand Down Expand Up @@ -197,9 +198,9 @@ CONTAINER_DEFINITIONS=$(
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "/ecs/$TESKDEFINITION_FAMILY",
"awslogs-group": "/ecs/$TASKDEFINITION_FAMILY",
"awslogs-create-group": "true",
"awslogs-region": "ap-south-1",
"awslogs-region": "$AWS_PUBLIC_REGION",
"awslogs-stream-prefix": "ecs"
},
"ulimits": []
Expand All @@ -212,7 +213,7 @@ EOF
TASK_DEFINITION=$(
cat <<EOF
{
"family": "$TESKDEFINITION_FAMILY",
"family": "$TASKDEFINITION_FAMILY",
"containerDefinitions": $CONTAINER_DEFINITIONS,
"executionRoleArn": "arn:aws:iam::${AWS_ACCOUNT_ID}:role/ecsTaskExecutionRole",
"volumes": [
Expand Down Expand Up @@ -281,18 +282,14 @@ task_id=$(echo "$service_description" | jq -r '.services[0].events[] | select(.m

# to fetch log group of container
.............................................................
log_group=/ecs/$TESKDEFINITION_FAMILY
log_group=/ecs/$TASKDEFINITION_FAMILY
echo "log_group=$log_group"

# Get Log Stream Name
log_stream=ecs/$CONTAINER_NAME/$task_id

echo "logstrem=$log_stream"


# Fetch logs
#echo "$(aws logs get-log-events --log-group-name "/ecs/$TESKDEFINITION_FAMILY/$CONTAINER_NAME" --log-stream-name "$log_stream" --region $AWS_PUBLIC_REGION)"

# Check if the token folder exists, and create it if it doesn't
token_folder="$PWD/agent-provisioning/AFJ/token"
if [ ! -d "$token_folder" ]; then
Expand All @@ -311,7 +308,7 @@ for attempt in $(seq 1 $RETRIES); do
token=$(aws logs get-log-events \
--log-group-name "$log_group" \
--log-stream-name "$log_stream" \
--region ap-southeast-1 \
--region $AWS_PUBLIC_REGION \
| grep -o '*** API Key: [^ ]*' \
| cut -d ' ' -f 3
)
Expand Down
5 changes: 2 additions & 3 deletions apps/agent-provisioning/src/agent-provisioning.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,18 @@
walletStorageHost,
walletStoragePassword,
walletStoragePort,
walletStorageUser,

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.
webhookEndpoint,
agentType,
protocol,
credoImage,
tenant,
indyLedger,
inboundEndpoint,
apiKey
inboundEndpoint
} = payload;
if (agentType === AgentType.AFJ) {
// The wallet provision command is used to invoke a shell script
const walletProvision = `${process.cwd() + process.env.AFJ_AGENT_SPIN_UP} ${orgId} "${externalIp}" "${walletName}" "${walletPassword}" ${seed} ${webhookEndpoint} ${walletStorageHost} ${walletStoragePort} ${walletStorageUser} ${walletStoragePassword} ${containerName} ${protocol} ${tenant} ${credoImage} "${indyLedger}" ${inboundEndpoint} ${process.env.SCHEMA_FILE_SERVER_URL} ${apiKey} ${process.env.AGENT_HOST} ${process.env.AWS_ACCOUNT_ID} ${process.env.S3_BUCKET_ARN} ${process.env.CLUSTER_NAME} ${process.env.TESKDEFINITION_FAMILY}`;
const walletProvision = `${process.cwd() + process.env.AFJ_AGENT_SPIN_UP} ${orgId} "${externalIp}" "${walletName}" "${walletPassword}" ${seed} ${webhookEndpoint} ${walletStorageHost} ${walletStoragePort} ${walletStorageUser} ${walletStoragePassword} ${containerName} ${protocol} ${tenant} ${credoImage} "${indyLedger}" ${inboundEndpoint} ${process.env.SCHEMA_FILE_SERVER_URL} ${process.env.AGENT_API_KEY} ${process.env.AGENT_HOST} ${process.env.AWS_ACCOUNT_ID} ${process.env.S3_BUCKET_ARN} ${process.env.CLUSTER_NAME} ${process.env.TASKDEFINITION_FAMILY}`;
const spinUpResponse: object = new Promise(async (resolve) => {
await exec(walletProvision, async (err, stdout, stderr) => {
this.logger.log(`shell script output: ${stdout}`);
Expand Down
2 changes: 1 addition & 1 deletion apps/agent-service/src/agent-service.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ export class AgentServiceService {
socket.emit('invitation-url-creation-started', { clientId: agentSpinupDto.clientSocketId });
}
const agentBaseWalletToken = await this.commonService.getBaseAgentToken(
agentDetails.gentEndPoint,
agentDetails.agentEndPoint,
agentDetails?.agentToken
);
if (!agentBaseWalletToken) {
Expand Down