Skip to content

Commit

Permalink
logging for Moodle autologin
Browse files Browse the repository at this point in the history
  • Loading branch information
anhefti committed Dec 11, 2024
1 parent 8280a73 commit 037ea8b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public final class InstitutionalAuthenticationEntryPoint implements Authenticati


private final String defaultLogo;
private final GuiServiceInfo guiServiceInfo;
private final WebserviceURIService webserviceURIService;
private final ClientHttpRequestFactoryService clientHttpRequestFactoryService;

Expand All @@ -73,11 +74,13 @@ public InstitutionalAuthenticationEntryPoint(
@Value("${sebserver.gui.defaultLogo:" + Constants.NO_NAME + "}") final String defaultLogoFileName,
final WebserviceURIService webserviceURIService,
final ClientHttpRequestFactoryService clientHttpRequestFactoryService,
final ResourceLoader resourceLoader) {
final ResourceLoader resourceLoader,
final GuiServiceInfo guiServiceInfo) {

this.guiEntryPoint = guiEntryPoint;
this.webserviceURIService = webserviceURIService;
this.clientHttpRequestFactoryService = clientHttpRequestFactoryService;
this.guiServiceInfo = guiServiceInfo;

String _defaultLogo;
if (!Constants.NO_NAME.equals(defaultLogoFileName)) {
Expand Down Expand Up @@ -132,11 +135,10 @@ public void commence(
}

if (authorizationContext.autoLogin(jwt)) {
final String uriString = "https://ralph.ethz.ch";
log.info("Autologin successful, redirect to: {}", uriString);
final String redirect = guiServiceInfo.getExternalServerURIBuilder().toUriString();
log.info("Autologin successful, redirect to: {}", redirect);
response.setStatus(HttpStatus.TEMPORARY_REDIRECT.value());
response.setHeader(HttpHeaders.LOCATION, uriString);
//forwardToEntryPoint(request, response, /* this.guiEntryPoint */ "/", true);
response.setHeader(HttpHeaders.LOCATION, redirect);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ public boolean isValid() {
public boolean isLoggedIn() {
final OAuth2AccessToken accessToken = this.restTemplate.getOAuth2ClientContext().getAccessToken();
if (accessToken == null || StringUtils.isEmpty(accessToken.toString())) {
log.warn("No Access Token for user: {}", this.restTemplate.getOAuth2ClientContext().getAccessTokenRequest().getHeaders());
return false;
}

Expand Down Expand Up @@ -293,9 +292,6 @@ public boolean autoLogin(final String oneTimeToken) {
final TokenLoginInfo loginInfo = response.getBody();
this.resource.setUsername(loginInfo.username);
this.resource.setPassword(loginInfo.userUUID);

// this.restTemplate.getOAuth2ClientContext().setAccessToken(null);
// this.restTemplate.getAccessToken();
this.restTemplate.getOAuth2ClientContext().setAccessToken(loginInfo.login);

loginForward = loginInfo.login_forward;
Expand Down

0 comments on commit 037ea8b

Please sign in to comment.