Coder Social home page Coder Social logo

Comments (12)

sk-keeper avatar sk-keeper commented on August 16, 2024

Aquí hay un enlace a la implementación predeterminada de la interfaz IAuthUI


Tiene una aplicación WinForms, por lo que se supone que la implementación del método GetUserCredentials (credenciales IUserCredentials) debe mostrar un formulario con campos de entrada de nombre de usuario y contraseña. El parámetro "credenciales", si no es nulo, puede contener la última información de usuario registrada.

Se supone que el método GetTwoFactorCode muestra un formulario que le pide al usuario que ingrese el código de autorización de Second Factor

from commander.

favy87 avatar favy87 commented on August 16, 2024

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024

De hecho, la biblioteca de la derecha declara que los métodos.

public interface IAuthUI

Su código a la izquierda necesita proporcionar implementación para estos métodos. Mostrar formulario de inicio de sesión de nombre de usuario / contraseña para el método "GetUserCredentials"
y formulario de código 2FA para "GetTwoFactorCode"

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024
private TaskCompletionSource<IUserCredentials> _credentials;
public Task<IUserCredentials> GetUserCredentials(IUserCredentials credentials)
            {
                // Show Login form
                _credentials = new TaskCompletionSource<IUserCredentials>();
                return _credentials.Task;
            }

            void SubmitLoginForm() { 
                var cred = new UserCredencials
                    {
                        Username = "username",
                        Password = "password"
                    };
                _credentials.SetResult(cred);
            }

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024

void CancelLoginForm() { _credentials.SetCanceled(); }

from commander.

favy87 avatar favy87 commented on August 16, 2024

Disculpame pero creo que es algo de los archivos DLL que se incluyen ya compilados.
Tengo el mismo codigo y dos librerias diferentes.

Esta libreria no tiene ese metodo implementado y falla en windows form
Commander-master\dotnet-keeper-sdk\KeeperSdk\bin\Debug\net45\KeeperSdk.dll

Esta libreria si que tiene ese metodo implemenado y funciona
Commander-master\dotnet-keeper-sdk\KeeperSdk\obj\Debug\netstandard2.0\KeeperSdk.dll

¿Podeis hacer el ejemplo de Commander con un WindowsForm? Por ejemplo un richtextbox para la consola y un textbox para introducir comandos?

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024

Se espera que el proyecto KeeperSdk construya tres DLL para tres objetivos .NET (.NET Framework, .Net Standard y .NET Core). Su proyecto utiliza el objetivo correcto. Puedo ver Debug \ net45 \ KeeperSdk.dll en la esquina inferior derecha de las capturas de pantalla. No creo que haya una aplicación de ejemplo de Commander para WinForms.

from commander.

favy87 avatar favy87 commented on August 16, 2024

Al final he simplificado mucho lo que queria y ha funcionado leyendo un caso cerrado de otro usuario y adaptandolo. Commander es mucho mas rapido en c# en responder que en python.

JsonConfigurationStorage storage = new JsonConfigurationStorage();
KeeperEndpoint ke = new KeeperEndpoint(storage);
AuthContext Auth = new AuthContext(ke, null);

//Initialize user configuration and set the login credentials.
UserConfiguration keeperLogin = new UserConfiguration();
keeperLogin.Username = "username";
keeperLogin.Password = "pass";

//Login to keeper
await Auth.Login(keeperLogin);

//Access the vault and sync down the data from the vault
Vault vault = new Vault(Auth);
await SyncDownExtension.SyncDown(vault);

PasswordRecord record = new PasswordRecord();
vault.TryGetRecord("xxxxxxx", out record);
MessageBox.Show( record.Password);

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024

This code works until the "Login" flow requires some user input.
For instance, provide 2FA code.

The following line of code, the null part of it
AuthContext Auth = new AuthContext(ke, null);
makes "login" flow fail if customer's account requires second factor authentication

I would not do that. I would support at least 2FA flow in the class implementing IAuthUI interface.
It is GetTwoFactorCode method. Any other methods may return default value or throw exception.
The implementation of GetTwoFactorCode method is quite simple for the WinForms application:

private TaskCompletionSource<string> _secondFactorTask;
public Task<string> GetTwoFactorCode()
{
   _secondFactorTask = new TaskCompletionSource<string>();
   //TODO Show "Enter 2FA Code" form
   return _secondFactorTask.Task;
}

// When customer clicks "OK" button on
void Submit2FACodeButtonClicked(string code) { 
  _secondFactorTask.SetResult(code);
}

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024

Screen Shot 2020-05-06 at 1 58 19 PM

Here is an example of 2FA form in the Web Vault

from commander.

favy87 avatar favy87 commented on August 16, 2024

Existe algo parecido a vault.dispose() ?

Tengo unos 500 registros y consume memoria, pasa de 20MB a 45MB en RAM despues de descargar la informacion. me gustaria una vez obtenido el password del registro que necesito, vaciar la memoria y seguir la ejecucion del prgrama.

from commander.

sk-keeper avatar sk-keeper commented on August 16, 2024

No, there is not need for Dispose. Just auth.Logout(); and set vault=null;. Memory will be released with the next garbage collector cycle

from commander.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.