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

Issue 16796 jwt pp auth 2 #19273

Merged
merged 66 commits into from
Sep 25, 2020
Merged

Issue 16796 jwt pp auth 2 #19273

merged 66 commits into from
Sep 25, 2020

Conversation

freddyucv
Copy link

@freddyucv freddyucv commented Sep 16, 2020

Use JWT to authenticate in Push Publish and Integrity Checker

@dsilvam dsilvam merged commit 7804256 into master Sep 25, 2020
@delete-merged-branch delete-merged-branch bot deleted the issue-16796-jwt-pp-auth_2 branch September 25, 2020 22:48

private void checkColumnSize(final String tableName) throws SQLException {
final Connection connection = DbConnectionFactory.getConnection();
final ResultSet resultSet = DotDatabaseMetaData.getColumnsMetaData(connection, tableName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

private void dropConstraint(final String tableName, final String constraintName) throws DotDataException {
DotConnect dc = new DotConnect();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import com.dotcms.publisher.pusher.AuthCredentialPushPublishUtil;

import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import java.util.Set;

import static com.dotcms.util.CollectionsUtils.list;
import static com.dotcms.util.CollectionsUtils.map;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @throws DotDataException
* @throws DotSecurityException
*/
public void executeFix(final String endpointId) throws DotDataException, DotSecurityException;
public void executeFix(final String key) throws DotDataException, DotSecurityException;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return String.format("bundle_%d.tar.gz", System.currentTimeMillis());
}

private boolean isAdmin(final User user) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


processing = false;

InputStream zipFile = response.readEntity(InputStream.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @throws JSONException
* An error occurred when generating the JSON response.
*/
private String getRemoteIP(@Context HttpServletRequest request) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -5,6 +5,7 @@
import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.business.WrapInTransaction;
import com.dotcms.enterprise.cluster.ClusterFactory;
import com.dotcms.publisher.pusher.PushPublisher;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

//Setting the process status
setStatus(session, endpoint.getId(), ProcessStatus.CANCELLED, null);
Logger.debug(IntegrityResource.class, "Requested interruption of the integrity checking process by the user.", e);
throw new RuntimeException("Requested interruption of the integrity checking process by the user.", e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: Avoid throwing raw exception types.

} catch (Exception e) {

//Special handling if the thread was interrupted
if (e instanceof InterruptedException) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dc.addParam("remote_identifier" + System.currentTimeMillis());
dc.addParam("html_page" + System.currentTimeMillis());
dc.addParam(remoteIP);
dc.addParam(new Long("1"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


private String insertPublishingEndPoint() throws DotDataException {

DotConnect dc = new DotConnect();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public enum AuthCredentialPushPublishUtil {
INSTANCE;

private final String BEARER = "Bearer ";

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy found an issue: This final field could be made static

import com.liferay.portal.model.User;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
* Provide util methods to get remote or local IP from {@link HttpServletRequest}
*/
public class RestEndPointIPUtil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


task05390RemoveEndpointIdForeignKeyInIntegrityResolverTables.executeUpgrade();

insertFolderIntegrityResolver("anyIP");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import com.dotcms.util.CollectionsUtils;
import com.dotcms.util.HttpRequestDataUtil;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UtilMethods;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WrapInTransaction
private Bundle publishBundle(final boolean forcePush,
final HttpServletRequest request,
final String remoteIP) throws Exception {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@QueryParam("FORCE_PUSH") final boolean forcePush,
@Context final HttpServletRequest request,
@Context final HttpServletResponse response
) throws Exception {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.client.Client;
import javax.ws.rs.*;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/**
* Provide util method for {@link IntegrityResource} and {@link BundleResource} classes
*/
public class PushPublishResourceUtil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

swicken-dotcms added a commit that referenced this pull request Jun 1, 2021
fmontes pushed a commit that referenced this pull request Jun 4, 2021
… content (#20346)

* #19723: Bringing hotfix (dotCMS/support@8331dd7) into core.

* #19273: Implemented suggested code changes to make limit param immutable

* Undo accidental merge of ext-properties.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants