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
1 change: 1 addition & 0 deletions aem/core_aem/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ service looks up the following OSGI configuration keys:
* `aio.api.key` your Adobe Developer Console jwt credential API Key (or Client ID) (`project.workspace.details.credentials[i].jwt.client_id`)
* `aio.client.secret` your Adobe Developer Console jwt credential client secret (`project.workspace.details.credentials[i].jwt.client_secret`)
* `aio.meta.scopes` a comma separated list of metascopes associated with your API, see your Adobe Developer Console jwt credential metascopes (`project.workspace.details.credentials[i].jwt.meta_scopes`)
* `aio_oauth_scopes` a comma separated list of OAuth scopes associated with your API, see your Adobe Developer Console OAuth scopes (project.workspace.details.credentials[i].oauth_server_to_server.scopes)
* `aio.technical.account.id` your Adobe Developer Console jwt credential technical account id (`project.workspace.details.credentials[i].jwt.technical_account_id`)
* `aio.encoded.pkcs8` your private key (in a base64 encoded pkcs8 format) see below

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.adobe.aio.aem.status.Status;
import com.adobe.aio.aem.workspace.WorkspaceSupplier;
import com.adobe.aio.aem.workspace.ocd.WorkspaceConfig;
import com.adobe.aio.auth.OAuthContext;
import com.adobe.aio.ims.util.PrivateKeyBuilder;
import com.adobe.aio.workspace.Workspace;
import java.security.PrivateKey;
Expand Down Expand Up @@ -92,6 +93,7 @@ private Map<String, String> getAuthConfigMap(
map.put(Workspace.TECHNICAL_ACCOUNT_ID, config.aio_technical_account_id());
map.put(Workspace.WORKSPACE_ID, config.aio_workspace_id());
map.put(Workspace.META_SCOPES, config.aio_meta_scopes());
map.put(OAuthContext.SCOPES, config.aio_oauth_scopes());
return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
description = "Adobe IMS URL: prod: https://ims-na1.adobelogin.com | stage: https://ims-na1-stg1.adobelogin.com")
String aio_ims_url() default "https://ims-na1.adobelogin.com";

@AttributeDefinition(name = "Meta Scopes",
description = "Comma separated list of metascopes associated with your API (`/s/event_receiver_api,/s/ent_adobeio_sdk` for instance) (project.workspace.details.credentials.jwt.meta_scopes)")
@AttributeDefinition(name = "JWT Meta Scopes",
description = "Comma separated list of metascopes associated with your API (`/s/event_receiver_api,/s/ent_adobeio_sdk` for instance) (project.workspace.details.credentials.jwt.meta_scopes), to be used with JWT.")
String aio_meta_scopes() default "/s/ent_adobeio_sdk";

@AttributeDefinition(name = "OAuth Scopes",
description = "Comma separated String. list of oauth scopes associated with your API (project.workspace.details.credentials.oauth_server_to_server.scopes)")
String aio_oauth_scopes();

@AttributeDefinition(name = "IMS ORG ID",
description = "Adobe IMS Organization ID as shown in your Adobe Developer Console workspace (project.org.ims_org_id)")
String aio_ims_org_id();
Expand Down
22 changes: 16 additions & 6 deletions core/src/main/java/com/adobe/aio/workspace/Workspace.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.adobe.aio.auth.Context;
import com.adobe.aio.auth.JwtContext;
import com.adobe.aio.auth.OAuthContext;
import com.adobe.aio.util.Constants;
import java.security.PrivateKey;
import java.util.Map;
Expand Down Expand Up @@ -202,6 +203,7 @@ public static class Builder {

private JwtContext.Builder jwtbuilder;
private Context authContext;
private OAuthContext.Builder oAuthBuilder;

private Builder() {
}
Expand Down Expand Up @@ -289,10 +291,15 @@ public Builder configMap(final Map<String, String> configMap) {
.consumerOrgId(configMap.get(CONSUMER_ORG_ID))
.projectId(configMap.get(PROJECT_ID))
.workspaceId(configMap.get(WORKSPACE_ID));

// For backwards compatibility - should this be kept?
jwtbuilder = JwtContext.builder();
jwtbuilder.configMap(configMap);
if(StringUtils.isNotBlank(configMap.get(JwtContext.META_SCOPES))) {
jwtbuilder = JwtContext.builder();
jwtbuilder.configMap(configMap);
}
if(StringUtils.isNotBlank(configMap.get(OAuthContext.SCOPES))) {
oAuthBuilder = OAuthContext.builder();
oAuthBuilder.configMap(configMap);
}
return this;
}

Expand All @@ -314,10 +321,13 @@ public Workspace build() {
if (authContext != null) {
return new Workspace(imsUrl, imsOrgId, apiKey, consumerOrgId, projectId, workspaceId, authContext);
}
if (jwtbuilder == null) {
jwtbuilder = JwtContext.builder();
if (jwtbuilder != null) {
return new Workspace(imsUrl, imsOrgId, apiKey, consumerOrgId, projectId, workspaceId, jwtbuilder.build());
} else if (oAuthBuilder != null) {
return new Workspace(imsUrl, imsOrgId, apiKey, consumerOrgId, projectId, workspaceId, oAuthBuilder.build());
} else {
throw new IllegalStateException("Missing auth confiugration, set either jwt or oauth...");
}
return new Workspace(imsUrl, imsOrgId, apiKey, consumerOrgId, projectId, workspaceId, jwtbuilder.build());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void projectUrl() {
}

@Test
public void jwtBackwardsCompat() throws Exception {
public void jwtBackwardsCompatible() throws Exception {
Workspace actual = Workspace.builder()
.imsUrl(Constants.IMS_URL)
.imsOrgId(Workspace.IMS_ORG_ID + TEST_VALUE)
Expand Down