Skip to content
This repository was archived by the owner on Dec 9, 2025. It is now read-only.

Commit 763711d

Browse files
authored
Merge pull request #90 from appirio-tech/dev
Release
2 parents b3bebab + bc078e1 commit 763711d

File tree

7 files changed

+66
-5
lines changed

7 files changed

+66
-5
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ workflows:
146146
context : org-global
147147
filters:
148148
branches:
149-
only: [dev, 'feature/jira-plat-152', 'auth0-kt']
149+
only: [dev, 'feature/jira-plat-152', 'update-keystore']
150150
# Production build is executed on "master" branch only.
151151
- "build-prod":
152152
context : org-global

build/build-image.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ echo "[CHECK THIS IS CORRECT] application domain: ${APPDOMAIN}"
9090

9191
echo "copying LDAP keystore file"
9292
#cp /mnt/ebs/deploy/topcoder/ap-identity/conf/$CONFIG/TC.prod.ldap.keystore $DOCKER_DIR/TC.prod.ldap.keystore
93-
aws s3 cp s3://appirio-platform-$CONFIG/application/tc-api-core/$CONFIG/TC.prod.ldap.keystore $DOCKER_DIR/TC.prod.ldap.keystore
93+
aws s3 cp s3://appirio-platform-$CONFIG/application/tc-api-core/$CONFIG/TC.prod.ldap.new.keystore $DOCKER_DIR/TC.prod.ldap.keystore
9494

9595
echo "copying environment-specific resources"
9696
cat $WORK_DIR/config/sumo-template.conf | sed -e "s/@APINAME@/${SERVICE}/g" | sed -e "s/@CONFIG@/${CONFIG}/g" > $DOCKER_DIR/sumo.conf

buildtokenproperties.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ DICEAUTH_DICE_API_URL=$(eval "echo \$${ENV}_DICEAUTH_DICE_API_URL")
1919
DICEAUTH_DICE_API_KEY=$(eval "echo \$${ENV}_DICEAUTH_DICE_API_KEY")
2020
DICEAUTH_CREDDEFID=$(eval "echo \$${ENV}_DICEAUTH_CREDDEFID")
2121
DICEAUTH_OTP_DURATION=$(eval "echo \$${ENV}_DICEAUTH_OTP_DURATION")
22+
SLACK_BOT_KEY=$(eval "echo \$${ENV}_SLACK_BOT_KEY")
23+
SLACK_CHANNEL_ID=$(eval "echo \$${ENV}_SLACK_CHANNEL_ID")
2224
ZENDESK_ID=$(eval "echo \$${ENV}_ZENDESK_ID")
2325
SERVICEACC02_UID=$(eval "echo \$${ENV}_SERVICEACC02_UID")
2426
AUTH_SECRET=$(eval "echo \$${ENV}_AUTH_SECRET")
@@ -92,6 +94,8 @@ perl -pi -e "s|\{\{DICEAUTH_DICE_API_URL\}\}|$DICEAUTH_DICE_API_URL|g" $CONFFILE
9294
perl -pi -e "s|\{\{DICEAUTH_DICE_API_KEY\}\}|$DICEAUTH_DICE_API_KEY|g" $CONFFILENAME
9395
perl -pi -e "s/\{\{DICEAUTH_CREDDEFID\}\}/$DICEAUTH_CREDDEFID/g" $CONFFILENAME
9496
perl -pi -e "s/\{\{DICEAUTH_OTP_DURATION\}\}/$DICEAUTH_OTP_DURATION/g" $CONFFILENAME
97+
perl -pi -e "s|\{\{SLACK_BOT_KEY\}\}|$SLACK_BOT_KEY|g" $CONFFILENAME
98+
perl -pi -e "s|\{\{SLACK_CHANNEL_ID\}\}|$SLACK_CHANNEL_ID|g" $CONFFILENAME
9599
perl -pi -e "s/\{\{ZENDESK_KEY\}\}/$ZENDESK_KEY/g" $CONFFILENAME
96100
perl -pi -e "s/\{\{ZENDESK_ID\}\}/$ZENDESK_ID/g" $CONFFILENAME
97101
perl -pi -e "s/\{\{SERVICEACC01_CID\}\}/$SERVICEACC01_CID/g" $CONFFILENAME

src/main/java/com/appirio/tech/core/service/identity/resource/UserResource.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ public class UserResource implements GetResource<User>, DDLResource<User> {
128128

129129
private String domain;
130130

131+
private String domainEnv;
132+
131133
private String sendgridTemplateId;
132134

133135
private String sendgridWelcomeTemplateId;
@@ -1337,6 +1339,7 @@ public ApiResponse updateStatus(
13371339
if(MemberStatus.UNVERIFIED == MemberStatus.getByValue(oldStatus) &&
13381340
MemberStatus.ACTIVE == MemberStatus.getByValue(user.getStatus())) {
13391341
notifyWelcome(userInDB);
1342+
assignDefaultUserRole(userInDB);
13401343
}
13411344

13421345
return ApiResponseFactory.createResponse(userInDB);
@@ -1648,11 +1651,14 @@ public ApiResponse updateUser2fa(
16481651
throw new APIRuntimeException(SC_BAD_REQUEST, "You have multiple accounts registered with same email. Please contact with support.");
16491652
}
16501653
}
1654+
Boolean oldMfaStatus = user2faInDb.getMfaEnabled() == null ? false : user2faInDb.getMfaEnabled();
1655+
Boolean oldDiceStatus = user2faInDb.getDiceEnabled() == null ? false : user2faInDb.getDiceEnabled();
1656+
String handle = user2faInDb.getHandle();
16511657
if (user2fa.getMfaEnabled() == null) {
1652-
user2fa.setMfaEnabled(user2faInDb.getMfaEnabled() == null ? false : user2faInDb.getMfaEnabled());
1658+
user2fa.setMfaEnabled(oldMfaStatus);
16531659
}
16541660
if (user2fa.getDiceEnabled() == null) {
1655-
user2fa.setDiceEnabled(user2faInDb.getDiceEnabled() == null ? false : user2faInDb.getDiceEnabled());
1661+
user2fa.setDiceEnabled(oldDiceStatus);
16561662
}
16571663
if (user2faInDb.getId() == null) {
16581664
long newId = userDao.insertUser2fa(userId, user2fa.getMfaEnabled(), user2fa.getDiceEnabled(),
@@ -1664,6 +1670,9 @@ public ApiResponse updateUser2fa(
16641670
user2fa.getDiceEnabled(), Utils.toLongValue(authUser.getUserId()));
16651671
user2faInDb = userDao.findUser2faById(user2faInDb.getId());
16661672
}
1673+
if (!oldDiceStatus.equals(user2faInDb.getDiceEnabled())) {
1674+
sendSlackNotification(handle, null, user2faInDb.getDiceEnabled() ? "DICE enabled :smile_cat:" : "DICE disabled :crying_cat_face:");
1675+
}
16671676
return ApiResponseFactory.createResponse(user2faInDb);
16681677
}
16691678

@@ -1702,6 +1711,7 @@ public ApiResponse getDiceConnection(
17021711
diceConnection.setCreatedAt(diceAttributes.getDiceConnectionCreatedAt());
17031712
diceConnection.setConnection(diceAuth.getDiceApiUrl() + "/web/connection/inviteurl/"
17041713
+ diceAttributes.getDiceConnection());
1714+
sendSlackNotification(diceAttributes.getHandle(), diceAttributes.getEmail(), "Reusing DICE connection");
17051715
return ApiResponseFactory.createResponse(diceConnection);
17061716
}
17071717
}
@@ -1730,6 +1740,7 @@ public ApiResponse getDiceConnection(
17301740
diceConnection.setId(newId);
17311741
diceConnection.setConnection(diceAuth.getDiceApiUrl() + "/web/connection/inviteurl/" + connectionId);
17321742
diceConnection.setAccepted(false);
1743+
sendSlackNotification(diceAttributes.getHandle(), diceAttributes.getEmail(), "Created new DICE connection");
17331744
return ApiResponseFactory.createResponse(diceConnection);
17341745
}
17351746

@@ -1846,6 +1857,7 @@ public ApiResponse issueCredentials(
18461857
response.getMessage()));
18471858
}
18481859
userDao.updateDiceConnectionStatus(user.getDiceConnectionId(), true);
1860+
sendSlackNotification(user.getHandle(), user.getEmail(), "DICE connection accepted");
18491861
return ApiResponseFactory.createResponse("SUCCESS");
18501862
}
18511863

@@ -2297,6 +2309,7 @@ public String getDomain() {
22972309

22982310
public void setDomain(String domain) {
22992311
this.domain = domain;
2312+
this.domainEnv = domain.toLowerCase().contains("dev") ? "DEV" : domain.toLowerCase().contains("qa") ? "QA" : "PROD";
23002313
}
23012314

23022315
public String getSendgridTemplateId() {
@@ -2454,6 +2467,21 @@ private void sendWelcomeEmailEvent(User user) {
24542467
logger.error("Error occured while publishing the events to new kafka.");
24552468
}
24562469
}
2470+
2471+
private void sendSlackNotification(String handle, String email, String message) {
2472+
ObjectMapper mapper = new ObjectMapper();
2473+
ObjectNode body = mapper.createObjectNode();
2474+
body.put("channel", diceAuth.getSlackChannelId());
2475+
body.put("text", String.format("[%s] %s%s : %s", domainEnv, handle, email == null ? "" : String.format(" (%s)", email) , message));
2476+
try {
2477+
new Request("https://slack.com/api/chat.postMessage", "POST")
2478+
.header("Authorization", "Bearer " + diceAuth.getSlackKey())
2479+
.json(mapper.writeValueAsString(body))
2480+
.execute();
2481+
} catch (Exception e) {
2482+
logger.error("Error when calling slack bot", e);
2483+
}
2484+
}
24572485

24582486
protected NotificationPayload createActivationNotificationPayload(User user, String redirectUrl) {
24592487
//If for Connect registration, send activation email with activation code only.

src/main/java/com/appirio/tech/core/service/identity/util/auth/DICEAuth.java

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,25 @@ public class DICEAuth {
1616
@NotNull
1717
private Integer otpDuration;
1818

19+
@NotNull
20+
private String slackKey;
21+
22+
@NotNull
23+
private String slackChannelId;
24+
1925
private String credPreview = "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/issue-credential/1.0/credential-preview";
2026

2127
public DICEAuth() {
2228
}
2329

24-
public DICEAuth(String diceApiUrl, String diceApiKey, String credDefId, Integer otpDuration) {
30+
public DICEAuth(String diceApiUrl, String diceApiKey, String credDefId, Integer otpDuration, String slackKey,
31+
String slackChannelId) {
2532
this.diceApiUrl = diceApiUrl;
2633
this.diceApiKey = diceApiKey;
2734
this.credDefId = credDefId;
2835
this.otpDuration = otpDuration;
36+
this.slackKey = slackKey;
37+
this.slackChannelId = slackChannelId;
2938
}
3039

3140
public String getDiceApiUrl() {
@@ -67,4 +76,20 @@ public String getCredPreview() {
6776
public void setCredPreview(String credPreview) {
6877
this.credPreview = credPreview;
6978
}
79+
80+
public String getSlackKey() {
81+
return slackKey;
82+
}
83+
84+
public void setSlackKey(String slackKey) {
85+
this.slackKey = slackKey;
86+
}
87+
88+
public String getSlackChannelId() {
89+
return slackChannelId;
90+
}
91+
92+
public void setSlackChannelId(String slackChannelId) {
93+
this.slackChannelId = slackChannelId;
94+
}
7095
}

src/main/resources/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ diceAuth:
9898
diceApiKey: @diceAuth.diceApiKey@
9999
credDefId: @diceAuth.credDefId@
100100
otpDuration: @diceAuth.otpDuration@
101+
slackKey: @diceAuth.slackKey@
102+
slackChannelId: @diceAuth.slackChannelId@
101103

102104
# Authorized accounts
103105
serviceAccount:

token.properties.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@
5555
@diceAuth.diceApiKey@={{DICEAUTH_DICE_API_KEY}}
5656
@diceAuth.credDefId@={{DICEAUTH_CREDDEFID}}
5757
@diceAuth.otpDuration@={{DICEAUTH_OTP_DURATION}}
58+
@diceAuth.slackKey@={{SLACK_BOT_KEY}}
59+
@diceAuth.slackChannelId@={{SLACK_CHANNEL_ID}}
5860

5961
@zendesk.secret@={{ZENDESK_KEY}}
6062
@zendesk.idprefix@={{ZENDESK_ID}}

0 commit comments

Comments
 (0)