GUACAMOLE-1364: Extract common SSO resource for IdP redirect.

This commit is contained in:
Michael Jumper
2021-12-03 21:12:06 -08:00
parent 0e9860ecf7
commit b6696b9dba
11 changed files with 48 additions and 121 deletions

View File

@@ -90,17 +90,7 @@ public class AuthenticationProviderService implements SSOAuthenticationProviderS
}
/**
* Returns the full URI of the CAS login endpoint to which a user must be
* redirected in order to authenticate and receive a CAS ticket.
*
* @return
* The full URI of the CAS login endpoint.
*
* @throws GuacamoleException
* If configuration information required for generating the login URI
* cannot be read.
*/
@Override
public URI getLoginURI() throws GuacamoleException {
return UriBuilder.fromUri(confService.getAuthorizationEndpoint())
.path(CAS_LOGIN_URI)

View File

@@ -20,6 +20,7 @@
package org.apache.guacamole.auth.cas;
import org.apache.guacamole.auth.sso.SSOAuthenticationProvider;
import org.apache.guacamole.auth.sso.SSOResource;
/**
* Guacamole authentication backend which authenticates users using an
@@ -35,7 +36,7 @@ public class CASAuthenticationProvider extends SSOAuthenticationProvider {
*/
public CASAuthenticationProvider() {
super(AuthenticationProviderService.class,
CASResource.class, new CASAuthenticationProviderModule());
SSOResource.class, new CASAuthenticationProviderModule());
}
@Override

View File

@@ -1,43 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.guacamole.auth.cas;
import com.google.inject.Inject;
import javax.ws.rs.core.Response;
import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.sso.SSOResource;
/**
* REST API resource that automatically redirects users to the CAS login
* endpoint.
*/
public class CASResource implements SSOResource {
/**
* Service for authenticating users using CAS.
*/
@Inject
private AuthenticationProviderService authService;
@Override
public Response redirectToIdentityProvider() throws GuacamoleException {
return Response.seeOther(authService.getLoginURI()).build();
}
}