Skip to content
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

Introduce implicit association identity provider configuration #506

Merged
merged 5 commits into from
Oct 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,9 @@ public enum ErrorMessage {
"Server encountered an error while retrieving the identity provider JIT config for identifier %s."),
ERROR_CODE_ERROR_RETRIEVING_IDP_GROUPS("65033", "Unable to retrieve identity provider group config.",
"Server encountered an error while retrieving the identity provider group config for identifier %s."),
ERROR_CODE_ERROR_RETRIEVING_IDP_ASSOCIATION("65034", "Unable to retrieve identity provider federated " +
"association config.", "Server encountered an error while retrieving the identity provider " +
"federated association config for identifier %s."),
ERROR_CODE_ERROR_RETRIEVING_IDP_CONNECTED_APPS("65042",
"Unable to retrieve identity provider connected applications.",
"Server encountered an error while retrieving the identity provider connected applications %s."),
Expand Down Expand Up @@ -244,6 +247,9 @@ public enum ErrorMessage {
"Unable to update identity provider groups.",
"Server encountered an error while updating the identity provider " +
"group config for identifier %s."),
ERROR_CODE_ERROR_UPDATING_IDP_ASSOCIATION("65037", "Unable to update identity provider federated " +
"association config.", "Server encountered an error while updating the identity provider " +
"federated association config for identifier %s."),
ERROR_CODE_ERROR_LISTING_IDP_TEMPLATES("65050", "Unable to list existing identity provider " +
"templates.", "Error occured while listing identity provider templates."),
ERROR_CODE_ERROR_ADDING_IDP_TEMPLATE("65051", "Unable to add IDP template.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.api.server.idp.v1;

Expand All @@ -23,6 +25,8 @@
import java.io.InputStream;
import java.util.List;

import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationRequest;
import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationResponse;
import org.wso2.carbon.identity.api.server.idp.v1.model.Claims;
import org.wso2.carbon.identity.api.server.idp.v1.model.ConnectedApps;
import org.wso2.carbon.identity.api.server.idp.v1.model.Error;
Expand Down Expand Up @@ -235,6 +239,30 @@ public Response getConnectedApps(@ApiParam(value = "ID of the identity provider.
return delegate.getConnectedApps(identityProviderId, limit, offset );
}

@Valid
@GET
@Path("/{identity-provider-id}/implicit-association")

@Produces({ "application/json" })
@ApiOperation(value = "Federated association config of an identity provider ", notes = "This API provides the federated association config of an identity provider. <br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/idpmgt/view <br> <b>Scope required:</b> <br> * internal_idp_view ", response = AssociationResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Association", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful response", response = AssociationResponse.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response getFederatedAssociationConfig(@ApiParam(value = "ID of the identity provider.",required=true) @PathParam("identity-provider-id") String identityProviderId) {

return delegate.getFederatedAssociationConfig(identityProviderId );
}

@Valid
@GET
@Path("/{identity-provider-id}/federated-authenticators/{federated-authenticator-id}")
Expand Down Expand Up @@ -694,6 +722,30 @@ public Response updateClaimConfig(@ApiParam(value = "ID of the identity provider
return delegate.updateClaimConfig(identityProviderId, claims );
}

@Valid
@PUT
@Path("/{identity-provider-id}/implicit-association")
@Consumes({ "application/json" })
@Produces({ "application/json" })
@ApiOperation(value = "Update the federated association config of an identity provider ", notes = "This API provides the capability to update the federated association config of an identity provider by specifying the identity provider ID. <br> <b>Permission required:</b> <br> * /permission/admin/manage/identity/idpmgt/update <br> <b>Scope required:</b> <br> * internal_idp_update ", response = AssociationResponse.class, authorizations = {
@Authorization(value = "BasicAuth"),
@Authorization(value = "OAuth2", scopes = {

})
}, tags={ "Association", })
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Successful response", response = AssociationResponse.class),
@ApiResponse(code = 400, message = "Bad Request", response = Error.class),
@ApiResponse(code = 401, message = "Unauthorized", response = Void.class),
@ApiResponse(code = 403, message = "Forbidden", response = Void.class),
@ApiResponse(code = 404, message = "Not Found", response = Error.class),
@ApiResponse(code = 500, message = "Server Error", response = Error.class)
})
public Response updateFederatedAssociationConfig(@ApiParam(value = "ID of the identity provider.",required=true) @PathParam("identity-provider-id") String identityProviderId, @ApiParam(value = "This represents the federated association config to be updated." ,required=true) @Valid AssociationRequest associationRequest) {

return delegate.updateFederatedAssociationConfig(identityProviderId, associationRequest );
}

@Valid
@PUT
@Path("/{identity-provider-id}/federated-authenticators/{federated-authenticator-id}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
/*
* Copyright (c) 2019, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.api.server.idp.v1;

Expand All @@ -23,6 +25,8 @@
import org.apache.cxf.jaxrs.ext.multipart.Multipart;
import java.io.InputStream;
import java.util.List;
import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationRequest;
import org.wso2.carbon.identity.api.server.idp.v1.model.AssociationResponse;
import org.wso2.carbon.identity.api.server.idp.v1.model.Claims;
import org.wso2.carbon.identity.api.server.idp.v1.model.ConnectedApps;
import org.wso2.carbon.identity.api.server.idp.v1.model.Error;
Expand Down Expand Up @@ -68,6 +72,8 @@ public interface IdentityProvidersApiService {

public Response getConnectedApps(String identityProviderId, Integer limit, Integer offset);

public Response getFederatedAssociationConfig(String identityProviderId);

public Response getFederatedAuthenticator(String identityProviderId, String federatedAuthenticatorId);

public Response getFederatedAuthenticators(String identityProviderId);
Expand Down Expand Up @@ -106,6 +112,8 @@ public interface IdentityProvidersApiService {

public Response updateClaimConfig(String identityProviderId, Claims claims);

public Response updateFederatedAssociationConfig(String identityProviderId, AssociationRequest associationRequest);

public Response updateFederatedAuthenticator(String identityProviderId, String federatedAuthenticatorId, FederatedAuthenticatorPUTRequest federatedAuthenticatorPUTRequest);

public Response updateFederatedAuthenticators(String identityProviderId, FederatedAuthenticatorRequest federatedAuthenticatorRequest);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright (c) 2023, WSO2 LLC. (http://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.wso2.carbon.identity.api.server.idp.v1.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.*;


import io.swagger.annotations.*;
import java.util.Objects;
import javax.validation.Valid;
import javax.xml.bind.annotation.*;

public class AssociationRequest {

private Boolean isEnabled;
private List<String> lookupAttribute = null;


/**
**/
public AssociationRequest isEnabled(Boolean isEnabled) {

this.isEnabled = isEnabled;
return this;
}

@ApiModelProperty(example = "false", value = "")
@JsonProperty("isEnabled")
@Valid
public Boolean getIsEnabled() {
return isEnabled;
}
public void setIsEnabled(Boolean isEnabled) {
this.isEnabled = isEnabled;
}

/**
**/
public AssociationRequest lookupAttribute(List<String> lookupAttribute) {

this.lookupAttribute = lookupAttribute;
return this;
}

@ApiModelProperty(example = "[\"email\"]", value = "")
@JsonProperty("lookupAttribute")
@Valid
public List<String> getLookupAttribute() {
return lookupAttribute;
}
public void setLookupAttribute(List<String> lookupAttribute) {
this.lookupAttribute = lookupAttribute;
}

public AssociationRequest addLookupAttributeItem(String lookupAttributeItem) {
if (this.lookupAttribute == null) {
this.lookupAttribute = new ArrayList<>();
}
this.lookupAttribute.add(lookupAttributeItem);
return this;
}



@Override
public boolean equals(java.lang.Object o) {

if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AssociationRequest associationRequest = (AssociationRequest) o;
return Objects.equals(this.isEnabled, associationRequest.isEnabled) &&
Objects.equals(this.lookupAttribute, associationRequest.lookupAttribute);
}

@Override
public int hashCode() {
return Objects.hash(isEnabled, lookupAttribute);
}

@Override
public String toString() {

StringBuilder sb = new StringBuilder();
sb.append("class AssociationRequest {\n");

sb.append(" isEnabled: ").append(toIndentedString(isEnabled)).append("\n");
sb.append(" lookupAttribute: ").append(toIndentedString(lookupAttribute)).append("\n");
sb.append("}");
return sb.toString();
}

/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {

if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n");
}
}

Loading