8000 fix: asset mgt new endpoints and compile time error for core and config-api by pujavs · Pull Request #8639 · JanssenProject/jans · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: asset mgt new endpoints and compile time error for core and config-api #8639

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 41 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
ad74527
fix(config-api): user attribute validation error handling
pujavs Apr 25, 2024
1ed77f2
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Apr 26, 2024
1e18060
fix(config-api): user attribute validation error handling
pujavs Apr 26, 2024
a25977c
fix(config-api): user attribute validation error handling
pujavs Apr 26, 2024
483ff35
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Apr 29, 2024
aae1be8
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Apr 30, 2024
8319446
fix: added new IDP attributes
pujavs Apr 30, 2024
d608621
fix: added new IDP attributes
pujavs Apr 30, 2024
2c25eb5
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 14, 2024
670d488
fix(config-api): idp default values set
pujavs May 15, 2024
9d265d8
fix(config-api): set important fields while configuring IDP to fix au…
pujavs May 15, 2024
42a5cd5
fix(config-api): idp metadata default values issue#8384
pujavs May 16, 2024
706eef0
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 17, 2024
6a386e6
feat: idp metadata default value and removing filepath in document-store
pujavs May 17, 2024
3e4b45c
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 17, 2024
f942fe0
feat: idp metadata default value and removing filepath in document-store
pujavs May 17, 2024
fd2de6d
fix: assetmgt and idp changes
pujavs May 17, 2024
e7aa37e
fix: assetmgt and idp changes
pujavs May 17, 2024
82ab7f5
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 20, 2024
91bb2cd
fix(config-api): validation for imp fields of asset mgt
pujavs May 20, 2024
461dffb
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 21, 2024
a54a3ba
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
p 8000 ujavs May 22, 2024
a51306f
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 23, 2024
7868af9
feat(config-api): pagination for get asset by name, asset filename an…
pujavs May 23, 2024
c344079
fix(config-api): added asset validation, removed redundant fields for TR
pujavs May 24, 2024
899625d
fix(config-api): agama swagger spec changes
pujavs May 24, 2024
aa8b58a
fix(config-api): agama swagger spec changes
pujavs May 24, 2024
c0c8f2b
fix(config-api): added asset validation, removed redundant fields for TR
pujavs May 24, 2024
cff488a
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 24, 2024
7ef4699
fix(config-api): added asset validation, removed redundant fields for TR
pujavs May 24, 2024
755c38a
fix(config-api): added asset validation, removed redundant fields for TR
pujavs May 24, 2024
bb308e4
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 27, 2024
a1c4f4c
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 28, 2024
73884cc
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 28, 2024
cae338b
feat(config-api): user mgt error handling
pujavs May 29, 2024
3b01e5e
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 29, 2024
1630c6b
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs May 30, 2024
4c96b9d
feat(config-api): user mgt error handling
pujavs May 31, 2024
7d1d979
feat(config-api): user mgt error handling
pujavs May 31, 2024
33f3b3b
Merge branch 'main' of https://github.com/JanssenProject/jans into ja…
pujavs Jun 3, 2024
8ab7a09
feat(config-api): asset mgt service module changes
pujavs Jun 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ public class AssetMgtConfiguration {
*/
private String assetBaseDirectory;

private List<String> jansServices;
/**
* List of supported service module where asset can be uploaded
*/
private List<String> jansServiceModule;

/**
* Asset type mapped to server directory
Expand Down Expand Up @@ -86,22 +89,19 @@ public void setAssetDirMapping(List<AssetDirMapping> assetDirMapping) {
this.assetDirMapping = assetDirMapping;
}

/**
* List of supported service module where asset can be uploaded
*/
public List<String> getJansServices() {
return jansServices;
public List<String> getJansServiceModule() {
return jansServiceModule;
}

public void setJansServices(List<String> jansServices) {
this.jansServices = jansServices;
public void setJansServiceModule(List<String> jansServiceModule) {
this.jansServiceModule = jansServiceModule;
}

@Override
public String toString() {
return "AssetMgtConfiguration [assetMgtEnabled=" + assetMgtEnabled + ", assetServerUploadEnabled="
+ assetServerUploadEnabled + ", fileExtensionValidationEnabled=" + fileExtensionValidationEnabled
+ ", moduleNameValidationEnabled=" + moduleNameValidationEnabled + ", assetBaseDirectory="
+ assetBaseDirectory + ", jansServices=" + jansServices + ", assetDirMapping=" + assetDirMapping + "]";
+ assetBaseDirectory + ", jansServiceModule=" + jansServiceModule + ", assetDirMapping=" + assetDirMapping + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ private ApiConstants() {}
public static final String JANS_ASSETS = "/jans-assets";
public static final String UPLOAD = "/upload";
public static final String STREAM = "/stream";
public static final String SERVICES = "/services";
public static final String ASSET_TYPE = "/asset-type";

public static final String APP_VERSION = "/app-version";
public static final String SERVER_STAT = "/server-stat";
Expand Down
90 changes: 78 additions & 12 deletions jans-config-api/docs/jans-config-api-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,72 @@ paths:
security:
- oauth2:
- https://jans.io/oauth/config/jans_asset-read
/api/v1/jans-assets/services:
get:
tags:
- Jans Assets
summary: Gets asset services
description: Gets asset services
operationId: get-asset-services
responses:
"200":
description: Ok
content:
application/json:
schema:
type: array
items:
type: string
"401":
description: Unauthorized
"404":
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
"500":
description: InternalServerError
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
security:
- oauth2:
- https://jans.io/oauth/config/jans_asset-read
/api/v1/jans-assets/asset-type:
get:
tags:
- Jans Assets
summary: Get valid asset types
description: Get valid asset types
operationId: get-asset-types
responses:
"200":
description: Ok
content:
application/json:
schema:
type: array
items:
type: string
"401":
description: Unauthorized
"404":
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
"500":
description: InternalServerError
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'
security:
- oauth2:
- https://jans.io/oauth/config/jans_asset-read
/api/v1/jans-assets/upload:
put:
tags:
Expand Down Expand Up @@ -8085,7 +8151,7 @@ components:
creationDate:
type: string
format: date-time
jansModuleProperty:
jansService:
type: array
items:
type: string
Expand Down Expand Up @@ -8243,18 +8309,18 @@ components:
type: boolean
whitePagesCanView:
type: boolean
adminCanView:
userCanView:
type: boolean
adminCanEdit:
type: boolean
userCanView:
type: boolean
userCanEdit:
type: boolean
userCanAccess:
adminCanView:
type: boolean
adminCanAccess:
type: boolean
userCanAccess:
type: boolean
baseDn:
type: string
PatchRequest:
Expand Down Expand Up @@ -9078,6 +9144,8 @@ components:
type: boolean
lockMessageConfig:
$ref: '#/components/schemas/LockMessageConfig'
fapi:
type: boolean
allResponseTypesSupported:
uniqueItems: true
type: array
Expand All @@ -9087,8 +9155,6 @@ components:
- code
- token
- id_token
fapi:
type: boolean
AuthenticationFilter:
required:
- baseDn
Expand Down Expand Up @@ -9854,10 +9920,10 @@ components:
type: array
items:
type: object
value:
type: object
displayValue:
type: string
value:
type: object
LocalizedString:
type: object
properties:
Expand Down Expand Up @@ -9972,7 +10038,7 @@ components:
type: boolean
assetBaseDirectory:
type: string
jansModules:
jansServiceModule:
type: array
items:
type: string
Expand Down Expand Up @@ -10573,10 +10639,10 @@ components:
ttl:
type: integer
format: int32
persisted:
type: boolean
opbrowserState:
type: string
persisted:
type: boolean
SessionIdAccessMap:
type: object
properties:
Expand Down
4 changes: 2 additions & 2 deletions jans-config-api/plugins/docs/user-mgt-plugin-swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -863,10 +863,10 @@ components:
type: array
items:
type: object
value:
type: object
displayValue:
type: string
value:
type: object
CustomUser:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.parameters.RequestBody;
import io.swagger.v3.oas.annotations.media.ArraySchema;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.ExampleObject;
import io.swagger.v3.oas.annotations.media.Schema;
Expand Down Expand Up @@ -161,6 +162,46 @@ public Response getAssetByName(
return Response.ok(documentPagedResult).build();
}

@Operation(summary = "Gets asset services", description = "Gets asset services", operationId = "get-asset-services", tags = {
"Jans Assets" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.JANS_ASSET_READ_ACCESS }))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = String.class, type = "enum")))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ApiError.class, description = "NotFoundException"))),
@ApiResponse(responseCode = "500", description = "InternalServerError", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ApiError.class, description = "InternalServerError"))) })
@GET
@ProtectedApi(scopes = { ApiAccessConstants.JANS_ASSET_READ_ACCESS }, groupScopes = {
ApiAccessConstants.JANS_ASSET_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS })
@Path(ApiConstants.SERVICES)
public Response getJansServices() {

List<String> services = assetService.getValidModuleName();

logger.info("Asset fetched based on services:{}", services);
return Response.ok(services).build();
}

@Operation(summary = "Get valid asset types", description = "Get valid asset types", operationId = "get-asset-types", tags = {
"Jans Assets" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.JANS_ASSET_READ_ACCESS }))
@ApiResponses(value = {
@ApiResponse(responseCode = "200", description = "Ok", content = @Content(mediaType = MediaType.APPLICATION_JSON, array = @ArraySchema(schema = @Schema(implementation = String.class, type = "enum")))),
@ApiResponse(responseCode = "401", description = "Unauthorized"),
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ApiError.class, description = "NotFoundException"))),
@ApiResponse(responseCode = "500", description = "InternalServerError", content = @Content(mediaType = MediaType.APPLICATION_JSON, schema = @Schema(implementation = ApiError.class, description = "InternalServerError"))) })
@GET
@ProtectedApi(scopes = { ApiAccessConstants.JANS_ASSET_READ_ACCESS }, groupScopes = {
ApiAccessConstants.JANS_ASSET_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS })
@Path(ApiConstants.ASSET_TYPE)
public Response getValidAssetTypes() {

List<String> validTypes = assetService.getValidFileExtension();

logger.info("validTypes:{}", validTypes);
return Response.ok(validTypes).build();
}

@Operation(summary = "Upload new asset", description = "Upload new asset", operationId = "post-new-asset", tags = {
"Jans Assets" }, security = @SecurityRequirement(name = "oauth2", scopes = {
ApiAccessConstants.JANS_ASSET_WRITE_ACCESS }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ public List<Document> getAssetByName(String name) throws Exception {
public PagedResult<Document> searchAssetByName(SearchRequest searchRequest) throws Exception {
log.info("Search asset with searchRequest:{}", searchRequest);

Filter nameFilter = Filter.createSubstringFilter(Filter.createLowercaseFilter(AttributeConstants.DISPLAY_NAME), null, new String[] { searchRequest.getFilter() },
null);
Filter nameFilter = Filter.createSubstringFilter(Filter.createLowercaseFilter(AttributeConstants.DISPLAY_NAME),
null, new String[] { searchRequest.getFilter() }, null);

log.debug("Asset Search nameFilter:{}", nameFilter);
return persistenceEntryManager.findPagedEntries(getDnForAsset(null), Document.class, nameFilter, null,
Expand Down Expand Up @@ -232,6 +232,29 @@ public boolean removeAsset(String inum) throws Exception {
return status;
}

public List<String> getValidModuleName() {
return this.appConfiguration.getAssetMgtConfiguration().getJansServiceModule();
}

public List<String> getValidFileExtension() {
List<String> validFileExtension = new ArrayList<>();

if (appConfiguration.getAssetMgtConfiguration().getAssetDirMapping() == null
|| appConfiguration.getAssetMgtConfiguration().getAssetDirMapping().isEmpty()) {
return validFileExtension;
}

List<AssetDirMapping> assetDir = this.appConfiguration.getAssetMgtConfiguration().getAssetDirMapping();

for (AssetDirMapping dir : assetDir) {
validFileExtension.addAll(dir.getType());
}

log.info("validFileExtension:{} - ", validFileExtension);

return validFileExtension;
}

private Document setAssetContent(Document asset, InputStream documentStream) throws IOException {
log.info(" Set asset content - asset:{}, documentStream:{}", asset, documentStream);
if (asset == null) {
Expand Down Expand Up @@ -282,7 +305,7 @@ private String copyAssetOnServer(Document asset, ByteArrayOutputStream stream) t
throw new InvalidConfigurationException("Asset stream is null!");
}

List<String> serviceModules = asset.getJansModuleProperty();
List<String> serviceModules = asset.getJansService();
String assetFileName = asset.getDisplayName();
String documentStoreModuleName = assetFileName;
log.info("Save asset for - serviceModules:{}, assetFileName:{}", serviceModules, assetFileName);
Expand Down Expand Up @@ -323,7 +346,7 @@ private boolean deleteAssetFromServer(Document asset) {
return deleteStatus;
}

List<String> serviceModules = asset.getJansModuleProperty();
List<String> serviceModules = asset.getJansService();
String assetFileName = asset.getDisplayName();

log.info("Asset to be deleted for serviceModules:{}, assetFileName:{}", serviceModules, assetFileName);
Expand Down Expand Up @@ -447,29 +470,6 @@ private boolean isModuleNameValidationEnabled() {
return this.appConfiguration.getAssetMgtConfiguration().isModuleNameValidationEnabled();
}

private List<String> getValidModuleName() {
return this.appConfiguration.getAssetMgtConfiguration().getJansModules();
}

private List<String> getValidFileExtension() {
List<String> validFileExtension = new ArrayList<>();

if (appConfiguration.getAssetMgtConfiguration().getAssetDirMapping() == null
|| appConfiguration.getAssetMgtConfiguration().getAssetDirMapping().isEmpty()) {
return validFileExtension;
}

List<AssetDirMapping> assetDir = this.appConfiguration.getAssetMgtConfiguration().getAssetDirMapping();

for (AssetDirMapping dir : assetDir) {
validFileExtension.addAll(dir.getType());
}

log.info("validFileExtension:{} - ", validFileExtension);

return validFileExtension;
}

private void validateFileExtension(Document asset) {

if (asset == null || appConfiguration.getAssetMgtConfiguration() == null
Expand Down Expand Up @@ -504,7 +504,7 @@ private void validateFileExtension(Document asset) {

private void validateModules(Document asset) {

if (asset == null || asset.getJansModuleProperty() == null || asset.getJansModuleProperty().isEmpty()) {
if (asset == null || asset.getJansService() == null || asset.getJansService().isEmpty()) {
throw new InvalidConfigurationException("Service module list is null or empty!");
}

Expand All @@ -515,7 +515,7 @@ private void validateModules(Document asset) {
return;
}

List<String> invalidModuleList = authUtil.findMissingElements(asset.getJansModuleProperty(), validModules);
List<String> invalidModuleList = authUtil.findMissingElements(asset.getJansService(), validModules);
log.info("invalidModuleList:{}", invalidModuleList);

if (invalidModuleList != null && !invalidModuleList.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public String saveDocument(String path, String description, String documentConte
oxDocument.setDn(dn);
oxDocument.setDescription(description);
oxDocument.setJansEnabled(true);
oxDocument.setJansModuleProperty(moduleList);
oxDocument.setJansService(moduleList);
documentService.addDocument(oxDocument);
return path;
} catch (Exception ex) {
Expand All @@ -126,7 +126,7 @@ public String saveDocumentStream(String path, String description, InputStream do
oxDocument.setDn(dn);
oxDocument.setDescription(description);
oxDocument.setJansEnabled(true);
oxDocument.setJansModuleProperty(moduleList);
oxDocument.setJansService(moduleList);
documentService.addDocument(oxDocument);
return path;
} catch (Exception e) {
Expand Down
Loading
0