Changeset 6768
- Timestamp:
- Jun 9, 2022, 8:49:13 AM (12 months ago)
- Location:
- extensions/net.sf.basedb.webauthn/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/net.sf.basedb.webauthn/trunk/resources/webauthn-login.js
r6759 r6768 35 35 event.preventDefault(); 36 36 var frm = document.forms['login']; 37 var login = frm.login.value 37 var login = frm.login.value; 38 var pwd = frm.password.value; 38 39 var home = Data.get(frm, 'home'); 39 40 var url = home+'/WebAuthn.servlet?ID='+App.getSessionId(); 40 41 url += '&cmd=StartWebAuthnLogin'; 41 42 url += '&login='+encodeURIComponent(login); 43 url += '&password='+encodeURIComponent(pwd); 42 44 43 45 try -
extensions/net.sf.basedb.webauthn/trunk/src/net/sf/basedb/webauthn/PreLoginAuthenticationManager.java
r6754 r6768 1 1 package net.sf.basedb.webauthn; 2 3 import com.yubico.webauthn.AssertionRequest;4 2 5 3 import net.sf.basedb.core.AuthenticationContext; … … 8 6 import net.sf.basedb.core.authentication.LoginException; 9 7 import net.sf.basedb.core.authentication.LoginRequest; 10 import net.sf.basedb.core.authentication.UnknownLoginException;11 8 import net.sf.basedb.core.data.UserData; 12 9 … … 40 37 String login = request.getLogin(); 41 38 42 // Check if the user exists and has configured a security key 43 UserData user = context.getUserByLogin(login); 44 if (user == null) throw new UnknownLoginException(login); 39 // Verify the login/password 40 AuthenticatedUser auth = context.verifyUserInternal(request); 41 42 // Check if a security key has been registered 43 UserData user = context.getUserById(auth.getInternalId()); 45 44 if (user.getExtended("webAuthnCredentialId") == null) 46 45 { … … 48 47 } 49 48 49 // Initiate the WebAuthn login process 50 50 String serverName = request.getAttribute("serverName"); 51 51 LoginProcessHandler handler = new LoginProcessHandler(user, serverName); 52 AssertionRequest assertionRequest = handler.getAssertionRequest();53 54 52 context.getSessionControl().setSessionSetting("webauthn-login-handler", handler); 55 throw new AssertionRequestException(assertionRequest); 53 // The AssertionRequest contains the information that need to be sent to the client 54 // This exception is catched and handled in WebAuthnServlet 55 throw new AssertionRequestException(handler.getAssertionRequest()); 56 56 } 57 57 -
extensions/net.sf.basedb.webauthn/trunk/src/net/sf/basedb/webauthn/WebAuthnServlet.java
r6761 r6768 71 71 { 72 72 String login = StringUtil.setNotNullString(Values.getStringOrNull(req.getParameter("login")), "User.Login", User.MAX_LOGIN_LENGTH); 73 String password = StringUtil.setNotNullString(Values.getStringOrNull(req.getParameter("password")), "User.Password", Integer.MAX_VALUE); 73 74 final SessionControl sc = Application.getSessionControl(ID, "net.sf.basedb.clients.web", req.getRemoteAddr(), false); 74 75 75 LoginRequest lr = new LoginRequest( );76 LoginRequest lr = new LoginRequest(login, password); 76 77 lr.setVerifyOnly(true); 77 lr.setLogin(login);78 78 lr.setAttribute("login-form", "net.sf.basedb.webauthn.pre-login"); 79 79 lr.setAttribute("serverName", req.getServerName());
Note: See TracChangeset
for help on using the changeset viewer.