Skip to content

Commit f9b5ce7

Browse files
authored
Merge branch 'main' into allow-token-exchange-if-at-least-one-token-is-not-revoked
2 parents 233e91d + 0fceb42 commit f9b5ce7

File tree

156 files changed

+3560
-2449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

156 files changed

+3560
-2449
lines changed

CHANGELOG.md

+72
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,75 @@
1+
## v2.72.15 - 2025-03-10
2+
3+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.14...v2.72.15)
4+
5+
## v2.72.14 - 2025-03-10
6+
7+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.13...v2.72.14)
8+
9+
## v2.72.13 - 2025-03-06
10+
11+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.12...v2.72.13)
12+
13+
## v2.72.12 - 2025-03-06
14+
15+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.11...v2.72.12)
16+
17+
## v2.72.11 - 2025-03-06
18+
19+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.10...v2.72.11)
20+
21+
## v2.72.10 - 2025-03-06
22+
23+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.9...v2.72.10)
24+
25+
## v2.72.9 - 2025-03-05
26+
27+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.8...v2.72.9)
28+
29+
## v2.72.8 - 2025-03-05
30+
31+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.7...v2.72.8)
32+
33+
## v2.72.7 - 2025-03-04
34+
35+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.6...v2.72.7)
36+
37+
## v2.72.6 - 2025-03-04
38+
39+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.5...v2.72.6)
40+
41+
## v2.72.5 - 2025-03-03
42+
43+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.4...v2.72.5)
44+
45+
## v2.72.4 - 2025-03-03
46+
47+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.3...v2.72.4)
48+
49+
- [#7235](https://github.com/ORCID/ORCID-Source/pull/7235): Fix switch user role
50+
51+
## v2.72.3 - 2025-03-03
52+
53+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.2...v2.72.3)
54+
55+
- [#7234](https://github.com/ORCID/ORCID-Source/pull/7234): Do not save the session on email verification events
56+
57+
## v2.72.2 - 2025-03-03
58+
59+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.1...v2.72.2)
60+
61+
## v2.72.1 - 2025-02-25
62+
63+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.72.0...v2.72.1)
64+
65+
## v2.72.0 - 2025-02-25
66+
67+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.71.22...v2.72.0)
68+
69+
## v2.71.23 - 2025-02-24
70+
71+
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.71.22...v2.71.23)
72+
173
## v2.71.22 - 2025-02-20
274

375
[Full Changelog](https://github.com/ORCID/ORCID-Source/compare/v2.71.21...v2.71.22)

orcid-api-common/src/main/java/org/orcid/api/common/jaxb/OrcidExceptionMapper.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,14 @@ public class OrcidExceptionMapper implements ExceptionMapper<Throwable> {
8888
public Response toResponse(Throwable t) {
8989
// Whatever exception has been caught, make sure we log it.
9090
String clientId = securityManager.getClientIdFromAPIRequest();
91-
if(t instanceof OrcidDeprecatedException
91+
if(t instanceof OrcidInvalidScopeException) {
92+
// This exception happens on client_credentials grant, so, the security manager doesn't have the client id info
93+
OrcidInvalidScopeException ex = (OrcidInvalidScopeException) t;
94+
if(clientId == null) {
95+
clientId = ex.getClientId();
96+
}
97+
logShortError(t, clientId);
98+
} else if(t instanceof OrcidDeprecatedException
9299
|| t instanceof LockedException
93100
|| t instanceof DeactivatedException
94101
|| t instanceof OrcidNoBioException

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

+5-2
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public Response obtainOauth2Token(String authorization, MultivaluedMap<String, S
131131
if(scopeType.isInternalScope()) {
132132
// You should not allow any internal scope here! go away!
133133
String message = localeManager.resolveMessage("apiError.9015.developerMessage", new Object[]{});
134-
throw new OrcidInvalidScopeException(message);
134+
throw new OrcidInvalidScopeException(message, clientId, scope);
135135
} else if(OrcidOauth2Constants.GRANT_TYPE_CLIENT_CREDENTIALS.equals(grantType)) {
136136
if(!scopeType.isClientCreditalScope())
137137
toRemove.add(scope);
@@ -147,7 +147,10 @@ public Response obtainOauth2Token(String authorization, MultivaluedMap<String, S
147147
}
148148
} catch (IllegalArgumentException iae) {
149149
String message = localeManager.resolveMessage("apiError.9015.developerMessage", new Object[]{});
150-
throw new OrcidInvalidScopeException(message);
150+
if(scopes != null) {
151+
message += " Provided scopes: " + String.join(",", scopes);
152+
}
153+
throw new OrcidInvalidScopeException(message, clientId, iae.getMessage());
151154
}
152155

153156
try{

orcid-core/pom.xml

+11-1
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,18 @@
326326
<dependency>
327327
<groupId>redis.clients</groupId>
328328
<artifactId>jedis</artifactId>
329-
<version>4.4.3</version>
329+
<version>3.7.1</version>
330330
</dependency>
331+
332+
333+
<!-- https://mvnrepository.com/artifact/org.json/json -->
334+
<dependency>
335+
<groupId>org.json</groupId>
336+
<artifactId>json</artifactId>
337+
<version>20240303</version>
338+
</dependency>
339+
340+
331341
</dependencies>
332342
<build>
333343
<plugins>

orcid-core/src/main/java/org/orcid/core/adapter/impl/MapperFacadeFactory.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
import org.orcid.persistence.jpa.entities.SourceAwareEntity;
110110
import org.orcid.persistence.jpa.entities.StartDateEntity;
111111
import org.orcid.persistence.jpa.entities.WorkEntity;
112+
import org.orcid.persistence.jpa.entities.keys.ClientRedirectUriPk;
112113
import org.orcid.pojo.ajaxForm.PojoUtil;
113114
import org.orcid.utils.OrcidStringUtils;
114115
import org.springframework.beans.factory.FactoryBean;
@@ -1040,10 +1041,10 @@ public void mapAtoB(Client a, ClientDetailsEntity b, MappingContext context) {
10401041
b.getClientRegisteredRedirectUris().add(existingEntity);
10411042
} else {
10421043
ClientRedirectUriEntity newEntity = new ClientRedirectUriEntity();
1043-
newEntity.setClientDetailsEntity(b);
1044-
newEntity.setPredefinedClientScope(ScopePathType.getScopesAsSingleString(cru.getPredefinedClientScopes()));
1044+
newEntity.setClientId(b.getClientId());
10451045
newEntity.setRedirectUri(cru.getRedirectUri());
10461046
newEntity.setRedirectUriType(cru.getRedirectUriType());
1047+
newEntity.setPredefinedClientScope(ScopePathType.getScopesAsSingleString(cru.getPredefinedClientScopes()));
10471048
newEntity.setUriActType(cru.getUriActType());
10481049
newEntity.setUriGeoArea(cru.getUriGeoArea());
10491050
b.getClientRegisteredRedirectUris().add(newEntity);

orcid-core/src/main/java/org/orcid/core/adapter/v3/impl/MapperFacadeFactory.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
import org.orcid.core.manager.SourceNameCacheManager;
3838
import org.orcid.core.manager.impl.OrcidUrlManager;
3939
import org.orcid.core.manager.v3.read_only.ClientDetailsManagerReadOnly;
40-
import org.orcid.core.togglz.Features;
4140
import org.orcid.core.utils.JsonUtils;
4241
import org.orcid.core.utils.SourceEntityUtils;
4342
import org.orcid.core.utils.v3.identifiers.PIDNormalizationService;
@@ -141,6 +140,7 @@
141140
import org.orcid.persistence.jpa.entities.SpamEntity;
142141
import org.orcid.persistence.jpa.entities.StartDateEntity;
143142
import org.orcid.persistence.jpa.entities.WorkEntity;
143+
import org.orcid.persistence.jpa.entities.keys.ClientRedirectUriPk;
144144
import org.orcid.pojo.WorkExtended;
145145
import org.orcid.pojo.WorkSummaryExtended;
146146
import org.orcid.pojo.ajaxForm.PojoUtil;
@@ -1198,10 +1198,10 @@ public void mapAtoB(Client a, ClientDetailsEntity b, MappingContext context) {
11981198
b.getClientRegisteredRedirectUris().add(existingEntity);
11991199
} else {
12001200
ClientRedirectUriEntity newEntity = new ClientRedirectUriEntity();
1201-
newEntity.setClientDetailsEntity(b);
1202-
newEntity.setPredefinedClientScope(ScopePathType.getScopesAsSingleString(cru.getPredefinedClientScopes()));
1201+
newEntity.setClientId(b.getClientId());
12031202
newEntity.setRedirectUri(cru.getRedirectUri());
12041203
newEntity.setRedirectUriType(cru.getRedirectUriType());
1204+
newEntity.setPredefinedClientScope(ScopePathType.getScopesAsSingleString(cru.getPredefinedClientScopes()));
12051205
newEntity.setUriActType(cru.getUriActType());
12061206
newEntity.setUriGeoArea(cru.getUriGeoArea());
12071207
newEntity.setStatus(ClientRedirectUriStatus.valueOf(cru.getStatus()));

orcid-core/src/main/java/org/orcid/core/cli/AddGrantTypeToExistingClients.java

+2-9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import org.orcid.jaxb.model.clientgroup.ClientType;
1212
import org.orcid.persistence.jpa.entities.ClientAuthorisedGrantTypeEntity;
1313
import org.orcid.persistence.jpa.entities.ClientDetailsEntity;
14+
import org.orcid.persistence.jpa.entities.keys.ClientAuthorisedGrantTypePk;
1415
import org.orcid.pojo.ajaxForm.PojoUtil;
1516
import org.springframework.context.ApplicationContext;
1617
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -49,11 +50,6 @@ public static void main(String [] args) {
4950
addGrantTypeToExistingClients.validateParameters(parser);
5051
addGrantTypeToExistingClients.init();
5152
addGrantTypeToExistingClients.process();
52-
System.out.println();
53-
System.out.println();
54-
System.out.println(addGrantTypeToExistingClients.getClientsUpdated() + " clients were updated");
55-
System.out.println();
56-
System.out.println();
5753
} catch (CmdLineException e) {
5854
System.err.println(e.getMessage());
5955
parser.printUsage(System.err);
@@ -110,14 +106,11 @@ private void updateGrantTypes(ClientDetailsEntity clientDetails) {
110106
if (!alreadyHaveGrantType) {
111107
ClientAuthorisedGrantTypeEntity newGrantType = new ClientAuthorisedGrantTypeEntity();
112108
newGrantType.setGrantType(grantType);
113-
newGrantType.setClientDetailsEntity(clientDetails);
109+
newGrantType.setClientId(clientDetails.getClientId());
114110
clientDetails.getClientAuthorizedGrantTypes().add(newGrantType);
115111

116112
clientDetailsManager.merge(clientDetails);
117113
clientsUpdated += 1;
118-
System.out.println("Client " + clientDetails.getId() + " has been updated");
119-
} else {
120-
System.out.println("Client " + clientDetails.getId() + " already have the " + grantType + " scope");
121114
}
122115
}
123116
}

orcid-core/src/main/java/org/orcid/core/cli/AddReadPublicScopeToNoneInstitutionMembers.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import org.orcid.jaxb.model.message.ScopePathType;
88
import org.orcid.persistence.jpa.entities.ClientDetailsEntity;
99
import org.orcid.persistence.jpa.entities.ClientScopeEntity;
10+
import org.orcid.persistence.jpa.entities.keys.ClientScopePk;
1011
import org.springframework.context.ApplicationContext;
1112
import org.springframework.context.support.ClassPathXmlApplicationContext;
1213
import org.springframework.transaction.TransactionStatus;
@@ -70,8 +71,9 @@ private void updateScopes(ClientDetailsEntity clientDetails) {
7071

7172
if (!alreadyHaveReadPublicScope) {
7273
ClientScopeEntity clientScope = new ClientScopeEntity();
73-
clientScope.setClientDetailsEntity(clientDetails);
74-
clientScope.setScopeType(ScopePathType.READ_PUBLIC.value());
74+
ClientScopePk pk = new ClientScopePk();
75+
pk.setClientId(clientDetails.getClientId());
76+
pk.setScopeType(ScopePathType.READ_PUBLIC.value());
7577
clientDetails.getClientScopes().add(clientScope);
7678
clientDetailsManager.merge(clientDetails);
7779
clientsUpdated += 1;

orcid-core/src/main/java/org/orcid/core/cli/AddScopesToExistingClients.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.orcid.jaxb.model.message.ScopePathType;
1313
import org.orcid.persistence.jpa.entities.ClientDetailsEntity;
1414
import org.orcid.persistence.jpa.entities.ClientScopeEntity;
15+
import org.orcid.persistence.jpa.entities.keys.ClientScopePk;
1516
import org.orcid.pojo.ajaxForm.PojoUtil;
1617
import org.springframework.context.ApplicationContext;
1718
import org.springframework.context.support.ClassPathXmlApplicationContext;
@@ -127,7 +128,7 @@ private void updateScopes(ClientDetailsEntity clientDetails) {
127128

128129
if (!alreadyHaveScope) {
129130
ClientScopeEntity clientScope = new ClientScopeEntity();
130-
clientScope.setClientDetailsEntity(clientDetails);
131+
clientScope.setClientId(clientDetails.getClientId());
131132
clientScope.setScopeType(scope.value());
132133
clientDetails.getClientScopes().add(clientScope);
133134
clientDetailsManager.merge(clientDetails);

orcid-core/src/main/java/org/orcid/core/cli/CreateNewClientSecrets.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ private void createFromFile() {
146146

147147
private void createNewClientSecret(ClientDetailsEntity clientDetails) {
148148
String clientSecret = UUID.randomUUID().toString();
149-
clientDetails.getClientSecrets().add(new ClientSecretEntity(encryptionManager.encryptForInternalUse(clientSecret), clientDetails));
149+
clientDetails.getClientSecrets().add(new ClientSecretEntity(encryptionManager.encryptForInternalUse(clientSecret), clientDetails.getClientId()));
150150
clientDetailsManager.merge(clientDetails);
151151
String output = String.format("%s\t%s\t%s\n", clientDetails.getId(), clientDetails.getClientName(), clientSecret);
152152
output(output);

orcid-core/src/main/java/org/orcid/core/common/manager/EventManager.java

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public interface EventManager {
1313

1414
void createEvent(EventType eventType, HttpServletRequest request);
1515

16+
void createReauthorizeEvent(String clientId);
17+
1618
void createPapiEvent(String clientId, String ip, boolean anonymous);
1719

1820
}

orcid-core/src/main/java/org/orcid/core/common/manager/impl/EventManagerImpl.java

+32-24
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.orcid.persistence.jpa.entities.EventEntity;
2121
import org.orcid.persistence.jpa.entities.EventType;
2222
import org.orcid.pojo.ajaxForm.PojoUtil;
23-
import org.orcid.pojo.ajaxForm.RequestInfoForm;
2423

2524
/**
2625
*
@@ -45,42 +44,51 @@ public void createEvent(EventType eventType, HttpServletRequest request) {
4544

4645
if (request != null) {
4746
Boolean isOauth2ScreensRequest = (Boolean) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_2SCREENS);
48-
RequestInfoForm requestInfoForm = (RequestInfoForm) request.getSession().getAttribute("requestInfoForm");
49-
if (requestInfoForm != null) {
50-
clientId = requestInfoForm.getClientId();
51-
label = "OAuth " + requestInfoForm.getMemberName() + " " + requestInfoForm.getClientName();
52-
} else if (isOauth2ScreensRequest != null && isOauth2ScreensRequest) {
47+
if (isOauth2ScreensRequest != null && isOauth2ScreensRequest) {
5348
String queryString = (String) request.getSession().getAttribute(OrcidOauth2Constants.OAUTH_QUERY_STRING);
5449
clientId = getParameterValue(queryString, "client_id");
55-
ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(clientId);
56-
String memberName = "";
57-
String clientName = clientDetailsEntity.getClientName();
58-
59-
if (ClientType.PUBLIC_CLIENT.equals(clientDetailsEntity.getClientType())) {
60-
memberName = "PubApp";
61-
} else if (!PojoUtil.isEmpty(clientDetailsEntity.getGroupProfileId())) {
62-
Name name = recordNameManagerReadOnly.getRecordName(clientDetailsEntity.getGroupProfileId());
63-
if (name != null) {
64-
memberName = name.getCreditName() != null ? name.getCreditName().getContent() : "";
65-
}
66-
}
67-
68-
if (StringUtils.isBlank(memberName)) {
69-
memberName = clientName;
70-
}
71-
label = "OAuth " + memberName + " " + clientName;
50+
label = generateLabel(clientId);
7251
}
7352
}
7453

7554
EventEntity eventEntity = new EventEntity();
76-
7755
eventEntity.setEventType(eventType.getValue());
7856
eventEntity.setClientId(clientId);
7957
eventEntity.setLabel(label);
8058
eventEntity.setDateCreated(new Date());
8159
eventDao.createEvent(eventEntity);
8260
}
8361

62+
@Override
63+
public void createReauthorizeEvent(String clientId) {
64+
EventEntity eventEntity = new EventEntity();
65+
eventEntity.setEventType(EventType.REAUTHORIZE.getValue());
66+
eventEntity.setClientId(clientId);
67+
eventEntity.setLabel(generateLabel(clientId));
68+
eventEntity.setDateCreated(new Date());
69+
eventDao.createEvent(eventEntity);
70+
}
71+
72+
private String generateLabel(String clientId) {
73+
ClientDetailsEntity clientDetailsEntity = clientDetailsEntityCacheManager.retrieve(clientId);
74+
String memberName = "";
75+
String clientName = clientDetailsEntity.getClientName();
76+
77+
if (ClientType.PUBLIC_CLIENT.equals(clientDetailsEntity.getClientType())) {
78+
memberName = "PubApp";
79+
} else if (!PojoUtil.isEmpty(clientDetailsEntity.getGroupProfileId())) {
80+
Name name = recordNameManagerReadOnly.getRecordName(clientDetailsEntity.getGroupProfileId());
81+
if (name != null) {
82+
memberName = name.getCreditName() != null ? name.getCreditName().getContent() : "";
83+
}
84+
}
85+
86+
if (StringUtils.isBlank(memberName)) {
87+
memberName = clientName;
88+
}
89+
return "OAuth " + memberName + " " + clientName;
90+
}
91+
8492
private String getParameterValue(String queryString, String parameter) {
8593
if (StringUtils.isNotEmpty(queryString)) {
8694
try {

0 commit comments

Comments
 (0)