Skip to content

Commit 9e7d5b9

Browse files
authored
Merge branch 'main' into 8802-add-field-that-identifies-search-and-link-wizards-to-dwclientdetails-in-panoply
2 parents 4e6741c + 5d2f3d6 commit 9e7d5b9

10 files changed

Lines changed: 84 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
## v2.39.0 - 2023-08-30
2+
3+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.10...v2.39.0)
4+
5+
- [#6882](https://github.com/ORCID/ORCID-Source/pull/6882): Add url to summary
6+
- [#6880](https://github.com/ORCID/ORCID-Source/pull/6880): Add url info to affiliations form
7+
8+
## v2.38.10 - 2023-08-23
9+
10+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.9...v2.38.10)
11+
12+
- [#6878](https://github.com/ORCID/ORCID-Source/pull/6878): Deactivate endpoint should return the email in a json object
13+
14+
## v2.38.9 - 2023-08-23
15+
16+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.8...v2.38.9)
17+
18+
- [#6877](https://github.com/ORCID/ORCID-Source/pull/6877): Remove tokens from cache
19+
20+
## v2.38.8 - 2023-08-22
21+
22+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.7...v2.38.8)
23+
24+
- [#6876](https://github.com/ORCID/ORCID-Source/pull/6876): Remove token from cache when it is revoked
25+
126
## v2.38.7 - 2023-08-18
227

328
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.38.6...v2.38.7)

orcid-api-common/src/main/java/org/orcid/api/common/oauth/OrcidClientCredentialEndPointDelegatorImpl.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.orcid.core.constants.OrcidOauth2Constants;
1717
import org.orcid.core.exception.OrcidInvalidScopeException;
1818
import org.orcid.core.locale.LocaleManager;
19-
import org.orcid.core.manager.EncryptionManager;
2019
import org.orcid.core.oauth.OAuthError;
2120
import org.orcid.core.oauth.OAuthErrorUtils;
2221
import org.orcid.core.utils.JsonUtils;
@@ -62,10 +61,7 @@ public class OrcidClientCredentialEndPointDelegatorImpl extends AbstractEndpoint
6261
private ProfileLastModifiedDao profileLastModifiedDao;
6362

6463
@Resource
65-
private RedisClient redisClient;
66-
67-
@Resource
68-
private EncryptionManager encryptionManager;
64+
private RedisClient redisClient;
6965

7066
@Value("${org.orcid.core.utils.cache.redis.enabled:true}")
7167
private boolean isTokenCacheEnabled;

orcid-core/src/main/java/org/orcid/core/oauth/service/OrcidOauth2TokenDetailServiceImpl.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
import org.orcid.core.constants.RevokeReason;
1212
import org.orcid.core.oauth.OrcidOauth2TokenDetailService;
13+
import org.orcid.core.utils.cache.redis.RedisClient;
1314
import org.orcid.jaxb.model.message.ScopePathType;
1415
import org.orcid.persistence.dao.OrcidOauth2TokenDetailDao;
1516
import org.orcid.persistence.jpa.entities.OrcidOauth2TokenDetail;
1617
import org.orcid.pojo.ajaxForm.PojoUtil;
1718
import org.slf4j.Logger;
1819
import org.slf4j.LoggerFactory;
20+
import org.springframework.beans.factory.annotation.Value;
1921
import org.springframework.cache.annotation.Cacheable;
2022
import org.springframework.security.oauth2.common.util.OAuth2Utils;
2123
import org.springframework.stereotype.Service;
@@ -34,6 +36,12 @@ public class OrcidOauth2TokenDetailServiceImpl implements OrcidOauth2TokenDetail
3436

3537
@Resource(name="orcidOauth2TokenDetailDaoReadOnly")
3638
private OrcidOauth2TokenDetailDao orcidOauth2TokenDetailDaoReadOnly;
39+
40+
@Resource
41+
private RedisClient redisClient;
42+
43+
@Value("${org.orcid.core.utils.cache.redis.enabled:true}")
44+
private boolean isTokenCacheEnabled;
3745

3846
@Override
3947
public void setOrcidOauth2TokenDetailDao(OrcidOauth2TokenDetailDao orcidOauth2TokenDetailDao) {
@@ -128,6 +136,11 @@ public void disableAccessToken(String accessToken) {
128136
@Override
129137
@Transactional
130138
public void revokeAccessToken(String accessToken) {
139+
// Remove the token from the cache
140+
if(isTokenCacheEnabled) {
141+
redisClient.remove(accessToken);
142+
}
143+
// Revoke the token
131144
orcidOauth2TokenDetailDao.revokeAccessToken(accessToken);
132145
}
133146

@@ -233,6 +246,16 @@ public void disableAccessTokenByUserOrcid(String userOrcid, RevokeReason reason)
233246
@Override
234247
@Transactional
235248
public void disableClientAccess(String clientDetailsId, String userOrcid) {
249+
// As a security measure, remove any user tokens from the cache
250+
List<OrcidOauth2TokenDetail> userTokens = findByUserName(userOrcid);
251+
if(userTokens != null && !userTokens.isEmpty()) {
252+
for(OrcidOauth2TokenDetail token : userTokens) {
253+
if(clientDetailsId.equals(token.getClientDetailsId())) {
254+
redisClient.remove(token.getTokenValue());
255+
}
256+
}
257+
}
258+
// And then disable all user tokens
236259
orcidOauth2TokenDetailDao.disableClientAccessTokensByUserOrcid(userOrcid, clientDetailsId);
237260
}
238261

orcid-core/src/main/java/org/orcid/core/utils/cache/redis/RedisClient.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,21 @@ public String get(String key) {
115115
LOG.debug("Reading Key: {}" , key);
116116
return jedis.get(key);
117117
}
118-
}
118+
}
119119
return null;
120-
}
120+
}
121+
122+
public boolean remove(String key) {
123+
if (enabled && pool != null) {
124+
try (Jedis jedis = pool.getResource()) {
125+
LOG.debug("Removing Key: {}", key);
126+
if (jedis.exists(key)) {
127+
return jedis.del(key) > 0;
128+
} else {
129+
return true;
130+
}
131+
}
132+
}
133+
return true;
134+
}
121135
}

orcid-core/src/main/java/org/orcid/pojo/ajaxForm/AffiliationForm.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ public static AffiliationForm valueOf(AffiliationSummary summary) {
192192
form.setAffiliationExternalIdentifiers(affiliationExternalIdentifiers);
193193
}
194194

195-
// Set empty url field
196-
form.setUrl(new Text());
195+
if(summary.getUrl() != null && summary.getUrl().getValue() != null) {
196+
form.setUrl(Text.valueOf(summary.getUrl().getValue()));
197+
}
197198

198199
form.setCreatedDate(Date.valueOf(summary.getCreatedDate()));
199200
form.setLastModified(Date.valueOf(summary.getLastModifiedDate()));

orcid-core/src/test/java/org/orcid/pojo/ajaxForm/AffiliationFormTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ public void equalsTest() {
2020
public void fromAffiliationSummaryTest() {
2121
AffiliationForm f1 = getAffiliationForm();
2222
AffiliationSummary s1 = getAffiliationSummary();
23-
// Summary doesn't have url
24-
f1.setUrl(new Text());
23+
24+
AffiliationForm f2 = AffiliationForm.valueOf(s1);
25+
f2.equals(f1);
2526
assertEquals(f1, AffiliationForm.valueOf(s1));
2627
}
2728

orcid-core/src/test/java/org/orcid/pojo/ajaxForm/AffiliationFormTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected AffiliationSummary getAffiliationSummary() {
160160
aff.setLastModifiedDate(new LastModifiedDate(lastModified));
161161
aff.setPutCode(1L);
162162
aff.setPath("/distinction/1");
163-
163+
aff.setUrl(new Url("https://test.orcid.org"));
164164
aff.setDepartmentName("department-name");
165165
aff.setDisplayIndex("0");
166166
aff.setEndDate(new FuzzyDate(new Year(2018), new Month(1), new Day(1)));

orcid-core/src/test/java/org/orcid/pojo/ajaxForm/AffiliationGroupFormTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ private AffiliationSummary getAff2() {
120120

121121
private AffiliationForm getForm1() {
122122
AffiliationForm affForm = getAffiliationForm();
123-
affForm.setUrl(new Text());
123+
affForm.setUrl(Text.valueOf("https://test.orcid.org"));
124124
affForm.setPutCode(Text.valueOf(2L));
125125

126126
Visibility v = new Visibility();
@@ -139,7 +139,7 @@ private AffiliationForm getForm1() {
139139

140140
private AffiliationForm getForm2() {
141141
AffiliationForm affForm = getAffiliationForm();
142-
affForm.setUrl(new Text());
142+
affForm.setUrl(Text.valueOf("https://test.orcid.org"));
143143
affForm.setPutCode(Text.valueOf(1L));
144144

145145
Visibility v = new Visibility();

orcid-web/src/main/java/org/orcid/frontend/web/controllers/ManageProfileController.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
import org.apache.commons.codec.binary.Base64;
1818
import org.apache.commons.lang.StringUtils;
19+
import org.codehaus.jettison.json.JSONException;
20+
import org.codehaus.jettison.json.JSONObject;
1921
import org.jasypt.exceptions.EncryptionOperationNotPossibleException;
2022
import org.orcid.core.constants.EmailConstants;
2123
import org.orcid.core.manager.AdminManager;
@@ -77,6 +79,8 @@
7779
import org.springframework.web.servlet.ModelAndView;
7880
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
7981

82+
import com.fasterxml.jackson.databind.JsonNode;
83+
8084
/**
8185
* @author Declan Newman (declan) Date: 22/02/2012
8286
*/
@@ -516,10 +520,13 @@ public ModelAndView confirmDeactivateOrcidAccount(HttpServletRequest request, Ht
516520
}
517521

518522
@RequestMapping(value = "/send-deactivate-account.json", method = RequestMethod.POST)
519-
public @ResponseBody String startDeactivateOrcidAccount(HttpServletRequest request) {
523+
public @ResponseBody String startDeactivateOrcidAccount(HttpServletRequest request) throws JSONException {
520524
String currentUserOrcid = getCurrentUserOrcid();
521525
recordEmailSender.sendOrcidDeactivateEmail(currentUserOrcid);
522-
return emailManager.findPrimaryEmail(currentUserOrcid).getEmail();
526+
String primaryEmail = emailManager.findPrimaryEmail(currentUserOrcid).getEmail();
527+
JSONObject response = new JSONObject();
528+
response.put("email", primaryEmail);
529+
return response.toString();
523530
}
524531

525532
@RequestMapping(value = "/emails.json", method = RequestMethod.GET)

orcid-web/src/main/java/org/orcid/frontend/web/controllers/PublicRecordController.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,9 +383,7 @@ RecordSummary getSummary(String orcid) {
383383
}
384384
}
385385
recordSummary.setName(displayName);
386-
}
387-
388-
ActivitiesSummary activitiesSummary = record.getActivitiesSummary();
386+
}
389387

390388
AffiliationGroupContainer groupedAffiliations = publicProfileController.getGroupedAffiliations(orcid);
391389
List<AffiliationGroupForm> groupedEmployments = groupedAffiliations.getAffiliationGroups().get(AffiliationType.EMPLOYMENT);

0 commit comments

Comments
 (0)