|
| 1 | + |
| 2 | + |
| 3 | +**Upsilon.Apps.Passkey.Core** |
| 4 | +============================================= |
| 5 | + |
| 6 | +**Overview** |
| 7 | +------------ |
| 8 | + |
| 9 | +This is a C# implementation of a local stored password manager core API. The API provides a secure way to store and manage passwords locally on a user's device. |
| 10 | + |
| 11 | +**Features** |
| 12 | +------------ |
| 13 | + |
| 14 | +* **Password Storage**: Store accounts and services passwords securely |
| 15 | +* **History log**: Log every events |
| 16 | +* **Trigger warnings**: Trigger warnings when detected |
| 17 | +* **Autosave**: Autosave updates |
| 18 | +* **Password Generation**: Generate strong, unique passwords |
| 19 | + |
| 20 | +**Security** |
| 21 | +------------ |
| 22 | + |
| 23 | +* **Encryption**: All passwords are encrypted using AES with a set of keys and RSA with a 1024-bit key |
| 24 | +* **Access Control**: Access to the password store is restricted to authorized users only |
| 25 | + |
| 26 | +**Models** |
| 27 | + |
| 28 | +---------- |
| 29 | + |
| 30 | +### Class diagram |
| 31 | + |
| 32 | + |
| 33 | +**Example Use Cases** |
| 34 | + |
| 35 | +-------------------- |
| 36 | + |
| 37 | +### Create a new database |
| 38 | + |
| 39 | +To create a new database, use the `IDatabase.Create` static method. |
| 40 | + |
| 41 | +This method needs an `ICryptographyCenter` implementation, an `ISerializationCenter` implementation and an `IPasswordFactory` implementation. |
| 42 | +The namespace `Upsilon.Apps.PassKey.Core.Public.Utils` already contains implementations for all of these intefaces. |
| 43 | + |
| 44 | +The next parameters are a set of files : the database file itself, the autosave file and the log file. |
| 45 | +These files will be created during the process. |
| 46 | + |
| 47 | +Finally, the method take the username and the passkeys. |
| 48 | +Note that the passkeys are used as master passwords to encrypt the database (and the other files). |
| 49 | + |
| 50 | +```csharp |
| 51 | +IDatabase database = IDatabase.Create(new Upsilon.Apps.PassKey.Core.Public.Utils.CryptographyCenter(), |
| 52 | + new Upsilon.Apps.PassKey.Core.Public.Utils.JsonSerializationCenter(), |
| 53 | + new Upsilon.Apps.PassKey.Core.Public.Utils.PasswordFactory(), |
| 54 | + "./database.pku", |
| 55 | + "./autosave.pks", |
| 56 | + "./log.pkl", |
| 57 | + "username", |
| 58 | + new string[] { "master_password_1", "master_password_2", "master_password_3" }); |
| 59 | +``` |
| 60 | + |
| 61 | +After creation, the method will directly open the database but it will not login directly to the current user. |
| 62 | +So to login, check the **Login to an user** use case. |
| 63 | + |
| 64 | +### Open an existing database |
| 65 | + |
| 66 | +To open an existing database, use the `IDatabase.Open` static method. |
| 67 | + |
| 68 | +This method needs the same `ICryptographyCenter` implementation, `ISerializationCenter` implementation and `IPasswordFactory` implementation as in the creation step. |
| 69 | + |
| 70 | +The next parameters are a set of files : the database file itself, the autosave file and the log file. |
| 71 | +The database file must, obviously, exist, the autosave file and log files are optional but must be the same as provided during the creating process. |
| 72 | + |
| 73 | +Finally, the method take the username. |
| 74 | + |
| 75 | +```csharp |
| 76 | +IDatabase database = IDatabase.Open(new Upsilon.Apps.PassKey.Core.Public.Utils.CryptographyCenter(), |
| 77 | + new Upsilon.Apps.PassKey.Core.Public.Utils.JsonSerializationCenter(), |
| 78 | + new Upsilon.Apps.PassKey.Core.Public.Utils.PasswordFactory(), |
| 79 | + "./database.pku", |
| 80 | + "./autosave.pks", |
| 81 | + "./log.pkl", |
| 82 | + "username"); |
| 83 | +``` |
| 84 | + |
| 85 | +### Login to an user |
| 86 | + |
| 87 | +After opening (or creating) a database, use the `IDatabase.Login` method to login the user. |
| 88 | +To do that, call the login method with every passkeys used during the database creation process. |
| 89 | +Only the last call of that method, with every correct and ordered passkeys, will return the `IUser` representing the current user successfuly loged in. |
| 90 | +Else that method will return `null`. |
| 91 | + |
| 92 | +```csharp |
| 93 | +IUser? user = database.Login("master_password_1"); // Will return null |
| 94 | +user = database.Login("master_password_2"); // Will also return null |
| 95 | +user = database.Login("master_password_3"); // Will return a IUser this time |
| 96 | +``` |
| 97 | + |
| 98 | +Once the IUser retrieved, it allow a full access to all services and accounts, all log history and all user parameters. |
| 99 | + |
| 100 | +### Saving the changes |
| 101 | + |
| 102 | +Use the `IDatabase.Save` method to save the user's updates. |
| 103 | +Note that any update on the user, its services and/or accounts which is not saved will be keeped in the autosave file. |
| 104 | + |
| 105 | +```csharp |
| 106 | +user.LogoutTimeout = 5; // Setting the logout timeout to 5 min will create an autosave file |
| 107 | +database.Save(); // Will save the new logout timeout in the database file and removed the autosave file |
| 108 | +``` |
| 109 | + |
| 110 | +### Logout/Close a database |
| 111 | + |
| 112 | +To logout and close the database, use the `IDatabase.Close` method. |
| 113 | +All unsaved updates are stored inside the autosave file. |
| 114 | + |
| 115 | +```csharp |
| 116 | +database.Close(); |
| 117 | +``` |
| 118 | + |
| 119 | +**Getting Started** |
| 120 | +------------------- |
| 121 | + |
| 122 | +1. Clone the repository: `git clone https://github.com/YassinLokhat/Upsilon.Apps.Passkey.Core.git` |
| 123 | +2. Build the solution: `dotnet build` |
| 124 | +3. Run the API: `dotnet run` |
| 125 | + |
| 126 | +**Contributing** |
| 127 | +------------ |
| 128 | + |
| 129 | +Contributions are welcome! Please submit a pull request with your changes. |
| 130 | + |
| 131 | +**License** |
| 132 | +------- |
| 133 | + |
| 134 | +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details. |
0 commit comments