mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
security fix, reuse session instead of passing the user to the state
This commit is contained in:
@@ -14,6 +14,7 @@ import com.commafeed.backend.dao.UserDAO;
|
|||||||
import com.commafeed.backend.feeds.OPMLImporter;
|
import com.commafeed.backend.feeds.OPMLImporter;
|
||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
|
import com.commafeed.frontend.CommaFeedSession;
|
||||||
import com.commafeed.frontend.utils.WicketUtils;
|
import com.commafeed.frontend.utils.WicketUtils;
|
||||||
import com.commafeed.frontend.utils.exception.DisplayException;
|
import com.commafeed.frontend.utils.exception.DisplayException;
|
||||||
import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl;
|
import com.google.api.client.auth.oauth2.AuthorizationCodeResponseUrl;
|
||||||
@@ -89,8 +90,7 @@ public class GoogleImportCallbackPage extends WebPage {
|
|||||||
BearerToken.authorizationHeaderAccessMethod().intercept(
|
BearerToken.authorizationHeaderAccessMethod().intercept(
|
||||||
httpRequest, accessToken);
|
httpRequest, accessToken);
|
||||||
String opml = httpRequest.execute().parseAsString();
|
String opml = httpRequest.execute().parseAsString();
|
||||||
String state = responseUrl.getState();
|
importer.importOpml(CommaFeedSession.get().getUser(), opml);
|
||||||
importer.importOpml(userDAO.findById(Long.valueOf(state)), opml);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DisplayException(e);
|
throw new DisplayException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import org.jboss.logging.Logger;
|
|||||||
|
|
||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
import com.commafeed.backend.services.ApplicationSettingsService;
|
import com.commafeed.backend.services.ApplicationSettingsService;
|
||||||
import com.commafeed.frontend.CommaFeedSession;
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class GoogleImportRedirectPage extends WebPage {
|
public class GoogleImportRedirectPage extends WebPage {
|
||||||
@@ -40,8 +39,6 @@ public class GoogleImportRedirectPage extends WebPage {
|
|||||||
builder.addParameter("scope", SCOPE);
|
builder.addParameter("scope", SCOPE);
|
||||||
builder.addParameter("approval_prompt", "force");
|
builder.addParameter("approval_prompt", "force");
|
||||||
builder.addParameter("client_id", clientId);
|
builder.addParameter("client_id", clientId);
|
||||||
builder.addParameter("state",
|
|
||||||
String.valueOf(CommaFeedSession.get().getUser().getId()));
|
|
||||||
|
|
||||||
throw new RedirectToUrlException(builder.build().toString());
|
throw new RedirectToUrlException(builder.build().toString());
|
||||||
} catch (URISyntaxException e) {
|
} catch (URISyntaxException e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user