From bf84b27fc0dc745f0640a2a8faedd2aecfda098a Mon Sep 17 00:00:00 2001 From: MaxKey Date: Mon, 17 Jul 2023 11:22:40 +0800 Subject: [PATCH] =?UTF-8?q?/sign/authz/cas/v1/tickets=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=8F=AA=E8=A6=81=E7=94=A8=E6=88=B7=E5=90=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=EF=BC=8C=E5=AF=86=E7=A0=81=E9=9A=8F=E4=BE=BF?= =?UTF-8?q?=E5=A1=AB=E9=83=BD=E8=83=BD=E9=80=9A=E8=BF=87=20#I7LC07?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../maxkey/authz/cas/endpoint/CasRestV1Endpoint.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java b/maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java index 7a68fe8d8..dca50c3fd 100644 --- a/maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java +++ b/maxkey-protocols/maxkey-protocol-cas/src/main/java/org/maxkey/authz/cas/endpoint/CasRestV1Endpoint.java @@ -43,6 +43,7 @@ import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.core.Authentication; import org.springframework.security.core.AuthenticationException; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; @@ -81,10 +82,14 @@ public class CasRestV1Endpoint extends CasBaseAuthorizeEndpoint{ throw new BadCredentialsException("No credentials are provided or extracted to authenticate the REST request"); } - LoginCredential loginCredential =new LoginCredential(username,password,"CASREST"); + LoginCredential loginCredential =new LoginCredential(username,password,"normal"); + + Authentication authentication = authenticationProvider.authenticate(loginCredential); + if(authentication == null) { + _logger.debug("Bad Credentials Exception"); + return new ResponseEntity<>("Bad Credentials", HttpStatus.BAD_REQUEST); + } - authenticationProvider.authenticate(loginCredential,false); - TicketGrantingTicketImpl ticketGrantingTicket=new TicketGrantingTicketImpl("Random",AuthorizationUtils.getAuthentication(),null); String ticket=casTicketGrantingTicketServices.createTicket(ticketGrantingTicket);