Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • getFacilities
  • get_facilities
  • main
  • makub/runnable_jar
  • mastalir/fix_ci
  • renovate/angular-cli-monorepo
  • renovate/angular-eslint-monorepo
  • renovate/angular-monorepo
  • renovate/angularmaterial-monorepo
  • renovate/bootstrap-5.x
  • renovate/core-js-3.x
  • renovate/lock-file-maintenance
  • renovate/node-16.x
  • renovate/nrwl-monorepo
  • session
  • zlamalp/bump2
  • zlamalp/test
  • zlamalp/testbuild
  • v0.1.0
  • v0.2.0
  • v0.2.1
  • v1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.1.0
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
  • v1.2.4
  • v1.2.5
  • v1.2.6
  • v1.3.0
  • v1.3.1
  • v1.3.10
  • v1.3.11
  • v1.3.12
  • v1.3.13
  • v1.3.14
  • v1.3.15
  • v1.3.16
  • v1.3.17
  • v1.3.18
  • v1.3.19
  • v1.3.2
  • v1.3.20
  • v1.3.21
  • v1.3.22
  • v1.3.23
  • v1.3.24
  • v1.3.25
  • v1.3.26
  • v1.3.27
  • v1.3.28
  • v1.3.29
  • v1.3.3
  • v1.3.30
  • v1.3.31
  • v1.3.32
  • v1.3.33
  • v1.3.34
  • v1.3.35
  • v1.3.36
  • v1.3.4
  • v1.3.5
  • v1.3.6
  • v1.3.7
  • v1.3.8
  • v1.3.9
  • v2.0.0
  • v2.0.1
  • v2.0.10
  • v2.0.11
  • v2.0.12
  • v2.0.2
  • v2.0.3
  • v2.0.4
  • v2.0.5
  • v2.0.6
  • v2.0.7
  • v2.0.8
  • v2.0.9
  • v2.1.0
  • v2.1.1
  • v2.1.10
  • v2.1.11
  • v2.1.12
  • v2.1.2
  • v2.1.3
  • v2.1.4
  • v2.1.5
  • v2.1.6
  • v2.1.7
  • v2.1.8
  • v2.1.9
  • v3.0.0
  • v3.0.1
  • v3.0.10
  • v3.0.11
  • v3.0.12
  • v3.0.13
  • v3.0.14
  • v3.0.15
  • v3.0.16
  • v3.0.17
  • v3.0.18
  • v3.0.19
  • v3.0.2
  • v3.0.20
  • v3.0.21
  • v3.0.22
  • v3.0.23
  • v3.0.24
  • v3.0.25
  • v3.0.26
  • v3.0.27
  • v3.0.28
118 results

Target

Select target project
  • perun/perun-proxyidp/v1/perun-spRegistration-app
1 result
Select Git revision
  • getFacilities
  • get_facilities
  • main
  • makub/runnable_jar
  • mastalir/fix_ci
  • renovate/angular-cli-monorepo
  • renovate/angular-eslint-monorepo
  • renovate/angular-monorepo
  • renovate/angularmaterial-monorepo
  • renovate/bootstrap-5.x
  • renovate/core-js-3.x
  • renovate/lock-file-maintenance
  • renovate/node-16.x
  • renovate/nrwl-monorepo
  • session
  • zlamalp/bump2
  • zlamalp/test
  • zlamalp/testbuild
  • v0.1.0
  • v0.2.0
  • v0.2.1
  • v1.0.0
  • v1.0.1
  • v1.0.2
  • v1.0.3
  • v1.1.0
  • v1.2.0
  • v1.2.1
  • v1.2.2
  • v1.2.3
  • v1.2.4
  • v1.2.5
  • v1.2.6
  • v1.3.0
  • v1.3.1
  • v1.3.10
  • v1.3.11
  • v1.3.12
  • v1.3.13
  • v1.3.14
  • v1.3.15
  • v1.3.16
  • v1.3.17
  • v1.3.18
  • v1.3.19
  • v1.3.2
  • v1.3.20
  • v1.3.21
  • v1.3.22
  • v1.3.23
  • v1.3.24
  • v1.3.25
  • v1.3.26
  • v1.3.27
  • v1.3.28
  • v1.3.29
  • v1.3.3
  • v1.3.30
  • v1.3.31
  • v1.3.32
  • v1.3.33
  • v1.3.34
  • v1.3.35
  • v1.3.36
  • v1.3.4
  • v1.3.5
  • v1.3.6
  • v1.3.7
  • v1.3.8
  • v1.3.9
  • v2.0.0
  • v2.0.1
  • v2.0.10
  • v2.0.11
  • v2.0.12
  • v2.0.2
  • v2.0.3
  • v2.0.4
  • v2.0.5
  • v2.0.6
  • v2.0.7
  • v2.0.8
  • v2.0.9
  • v2.1.0
  • v2.1.1
  • v2.1.10
  • v2.1.11
  • v2.1.12
  • v2.1.2
  • v2.1.3
  • v2.1.4
  • v2.1.5
  • v2.1.6
  • v2.1.7
  • v2.1.8
  • v2.1.9
  • v3.0.0
  • v3.0.1
  • v3.0.10
  • v3.0.11
  • v3.0.12
  • v3.0.13
  • v3.0.14
  • v3.0.15
  • v3.0.16
  • v3.0.17
  • v3.0.18
  • v3.0.19
  • v3.0.2
  • v3.0.20
  • v3.0.21
  • v3.0.22
  • v3.0.23
  • v3.0.24
  • v3.0.25
  • v3.0.26
  • v3.0.27
  • v3.0.28
118 results
Show changes

Commits on Source 3

## [5.0.2](https://gitlab.ics.muni.cz/perun-proxy-aai/java/perun-spRegistration-app/compare/v5.0.1...v5.0.2) (2023-03-14)
### Bug Fixes
* 🐛 fix login loop and default angular base href ([b632418](https://gitlab.ics.muni.cz/perun-proxy-aai/java/perun-spRegistration-app/commit/b63241818c083448bdb146a4eaa80b4b9f086783))
## [5.0.1](https://gitlab.ics.muni.cz/perun-proxy-aai/java/perun-spRegistration-app/compare/v5.0.0...v5.0.1) (2023-03-14) ## [5.0.1](https://gitlab.ics.muni.cz/perun-proxy-aai/java/perun-spRegistration-app/compare/v5.0.0...v5.0.1) (2023-03-14)
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<groupId>cz.metacentrum.perun</groupId> <groupId>cz.metacentrum.perun</groupId>
<artifactId>spRegistration</artifactId> <artifactId>spRegistration</artifactId>
<version>5.0.1</version> <version>5.0.2</version>
<packaging>war</packaging> <packaging>war</packaging>
<name>perun-spRegistration</name> <name>perun-spRegistration</name>
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
<bc-mail.version>${bc.version}</bc-mail.version> <bc-mail.version>${bc.version}</bc-mail.version>
<bc-pkix.version>${bc.version}</bc-pkix.version> <bc-pkix.version>${bc.version}</bc-pkix.version>
<!-- OTHER --> <!-- OTHER -->
<server.contextPath>/spreg</server.contextPath> <angular.base.href>/</angular.base.href>
<angular.base.href>${server.contextPath}/</angular.base.href>
<angular.api.url>http://localhost:8080/spreg/api</angular.api.url> <angular.api.url>http://localhost:8080/spreg/api</angular.api.url>
</properties> </properties>
......
...@@ -35,6 +35,21 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa ...@@ -35,6 +35,21 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa
Authentication authentication) Authentication authentication)
throws ServletException, IOException throws ServletException, IOException
{ {
trySetUser(
request,
authentication,
appBeansContainer.getApplicationProperties().getProxyIdentifier(),
appBeansContainer.getAttributesProperties().getNames().getUserEmail(),
appBeansContainer.getPerunAdapter()
);
super.onAuthenticationSuccess(request, response, authentication);
}
public static void trySetUser(HttpServletRequest request,
Authentication authentication,
String proxyIdentifier,
String userEmailAttr,
PerunAdapter perunAdapter) {
if (authentication != null && authentication.getAuthorities() != null) { if (authentication != null && authentication.getAuthorities() != null) {
log.debug("User '{}' has logged in", authentication.getName()); log.debug("User '{}' has logged in", authentication.getName());
...@@ -43,8 +58,7 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa ...@@ -43,8 +58,7 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa
boolean isAdmin = authentication.getAuthorities() != null boolean isAdmin = authentication.getAuthorities() != null
&& authentication.getAuthorities().contains(SecurityConfiguration.ROLE_ADMIN); && authentication.getAuthorities().contains(SecurityConfiguration.ROLE_ADMIN);
try { try {
User u = adapter.getUserWithEmail(sub, appBeansContainer.getApplicationProperties().getProxyIdentifier(), User u = perunAdapter.getUserWithEmail(sub, proxyIdentifier, userEmailAttr);
appBeansContainer.getAttributesProperties().getNames().getUserEmail());
if (u != null) { if (u != null) {
u.setAppAdmin(isAdmin); u.setAppAdmin(isAdmin);
} }
...@@ -59,7 +73,6 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa ...@@ -59,7 +73,6 @@ public class AuthSuccessHandler extends SavedRequestAwareAuthenticationSuccessHa
log.debug("Details: ", e); log.debug("Details: ", e);
} }
} }
super.onAuthenticationSuccess(request, response, authentication);
} }
} }
package cz.metacentrum.perun.spRegistration.web.controllers; package cz.metacentrum.perun.spRegistration.web.controllers;
import cz.metacentrum.perun.spRegistration.common.configs.AppBeansContainer;
import cz.metacentrum.perun.spRegistration.common.models.User; import cz.metacentrum.perun.spRegistration.common.models.User;
import cz.metacentrum.perun.spRegistration.persistence.adapters.PerunAdapter;
import cz.metacentrum.perun.spRegistration.web.AuthSuccessHandler;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -19,9 +23,25 @@ public class AuthController { ...@@ -19,9 +23,25 @@ public class AuthController {
public static final String SESS_ATTR_USER = "user"; public static final String SESS_ATTR_USER = "user";
private final PerunAdapter adapter;
private final AppBeansContainer appBeansContainer;
public AuthController(PerunAdapter adapter, AppBeansContainer appBeansContainer) {
super();
this.adapter = adapter;
this.appBeansContainer = appBeansContainer;
}
@GetMapping(path = "/api/getUser") @GetMapping(path = "/api/getUser")
public User getUser(HttpServletRequest req) { public User getUser(HttpServletRequest req, Authentication authentication) {
HttpSession sess = req.getSession(); HttpSession sess = req.getSession();
AuthSuccessHandler.trySetUser(
req,
authentication,
appBeansContainer.getApplicationProperties().getProxyIdentifier(),
appBeansContainer.getAttributesProperties().getNames().getUserEmail(),
appBeansContainer.getPerunAdapter()
);
if (sess == null || sess.getAttribute(SESS_ATTR_USER) == null) { if (sess == null || sess.getAttribute(SESS_ATTR_USER) == null) {
return null; return null;
} }
......