Added avatar retrieve/update at every login (#19726)
This commit is contained in:
parent
b0a19768fd
commit
705b9129da
|
@ -1,7 +1,9 @@
|
||||||
|
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
# Changelog for "oidc-enrollment-hook"
|
# Changelog for "oidc-enrollment-hook"
|
||||||
|
|
||||||
|
## [v1.1.0-SNAPSHOT]
|
||||||
|
- Added avatar retrieve/update at every login (#19726)
|
||||||
|
|
||||||
## [v1.0.0-SNAPSHOT]
|
## [v1.0.0-SNAPSHOT]
|
||||||
- First release (#19143) (#19225) (#19226) (#19227) (#19228)
|
- First release (#19143) (#19225) (#19226) (#19227) (#19228)
|
||||||
|
|
||||||
|
|
||||||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
25
profile.xml
25
profile.xml
|
@ -1,25 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
|
||||||
<ID></ID>
|
|
||||||
<Type>Portlet</Type>
|
|
||||||
<Profile>
|
|
||||||
<Description>${project.description}</Description>
|
|
||||||
<Class>PortletUser</Class>
|
|
||||||
<Name>${project.artifactId}</Name>
|
|
||||||
<Version>1.0.0</Version>
|
|
||||||
<Packages>
|
|
||||||
<Software>
|
|
||||||
<Name>${project.artifactId}</Name>
|
|
||||||
<Description>${project.description}</Description>
|
|
||||||
<MavenCoordinates>
|
|
||||||
<groupId>${project.groupId}</groupId>
|
|
||||||
<artifactId>${project.artifactId}</artifactId>
|
|
||||||
<version>${project.version}</version>
|
|
||||||
</MavenCoordinates>
|
|
||||||
<Files>
|
|
||||||
<File>${project.build.finalName}.${project.packaging}</File>
|
|
||||||
</Files>
|
|
||||||
</Software>
|
|
||||||
</Packages>
|
|
||||||
</Profile>
|
|
||||||
</Resource>
|
|
|
@ -1,18 +0,0 @@
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<descriptors>
|
|
||||||
<descriptor>descriptor.xml</descriptor>
|
|
||||||
</descriptors>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>servicearchive</id>
|
|
||||||
<phase>install</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>single</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
|
@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
import org.gcube.oidc.URLEncodedContextMapper;
|
import org.gcube.oidc.URLEncodedContextMapper;
|
||||||
import org.gcube.oidc.rest.JWTToken;
|
import org.gcube.oidc.rest.JWTToken;
|
||||||
|
import org.gcube.oidc.rest.OpenIdConnectRESTHelper;
|
||||||
|
|
||||||
import com.liferay.portal.kernel.exception.PortalException;
|
import com.liferay.portal.kernel.exception.PortalException;
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
import com.liferay.portal.kernel.exception.SystemException;
|
||||||
|
@ -21,6 +22,7 @@ import com.liferay.portal.model.User;
|
||||||
import com.liferay.portal.security.auth.BaseAutoLogin;
|
import com.liferay.portal.security.auth.BaseAutoLogin;
|
||||||
import com.liferay.portal.service.ServiceContext;
|
import com.liferay.portal.service.ServiceContext;
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
import com.liferay.portal.service.UserServiceUtil;
|
||||||
import com.liferay.portal.util.PortalUtil;
|
import com.liferay.portal.util.PortalUtil;
|
||||||
import com.liferay.util.PwdGenerator;
|
import com.liferay.util.PwdGenerator;
|
||||||
|
|
||||||
|
@ -115,6 +117,13 @@ public class OpenIdConnectAutoLogin extends BaseAutoLogin {
|
||||||
if (updateUser) {
|
if (updateUser) {
|
||||||
UserLocalServiceUtil.updateUser(user);
|
UserLocalServiceUtil.updateUser(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] userAvatar = OpenIdConnectRESTHelper.getUserAvatar(configuration.getAvatarURL(), token);
|
||||||
|
if (userAvatar != null) {
|
||||||
|
UserServiceUtil.updatePortrait(user.getUserId(), userAvatar);
|
||||||
|
} else {
|
||||||
|
UserServiceUtil.deletePortrait(user.getUserId());
|
||||||
|
}
|
||||||
} catch (SystemException | PortalException e) {
|
} catch (SystemException | PortalException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,3 +7,4 @@ d4science.oidc-scope=openid profile email
|
||||||
d4science.oidc-logout=https://nubis2.int.d4science.net/auth/realms/d4science/protocol/openid-connect/logout
|
d4science.oidc-logout=https://nubis2.int.d4science.net/auth/realms/d4science/protocol/openid-connect/logout
|
||||||
d4science.oidc-logout-on-portal-logout=true
|
d4science.oidc-logout-on-portal-logout=true
|
||||||
d4science.oidc-create-unexisting-user=true
|
d4science.oidc-create-unexisting-user=true
|
||||||
|
d4science.oidc-keycloak_avatar=https://nubis2.int.d4science.net/realms/d4science/avatar-provider/avatar
|
Loading…
Reference in New Issue