-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
196 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Copyright 2024 Carlos Henrique <[email protected]> | ||
|
||
Licensed 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. | ||
|
||
Additional Rules: | ||
|
||
1. You must retain the original copyright notice and license information when distributing the software or any modifications created from it. | ||
2. This software is provided "as is," without any warranties or conditions of any kind, either express or implied, including but not limited to the implied warranties or conditions of merchantability, fitness for a particular purpose, or non-infringement. | ||
3. In no event shall the authors or copyright holders be held liable for any claims, damages, or other liabilities arising out of the use or inability to use the software. | ||
4. You are not allowed to use the name of the copyright holder for any endorsement or promotional purposes without prior written permission. | ||
5. Contributions to the software are welcome, but by submitting a contribution, you agree to license the contribution under the same license terms as the original software. | ||
|
||
Please refer to the full Apache License, Version 2.0 for the complete set of terms and conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
# 2auth | ||
A simple 2-factor authentication manager in OTP (ONE TIME PASSWORD). | ||
|
||
[![Apache-2.0 License](https://img.shields.io/github/license/pompomdev/2auth)](https://opensource.org/licenses/Apache-2.0) | ||
[![GitHub Repo](https://img.shields.io/badge/Github-2auth-blue)](https://github.com/pompomdev/2auth) | ||
|
||
2auth is a software that provides two-factor authentication using One-Time Passwords (OTP). It allows users to save their authentication entries and generate OTP codes. | ||
|
||
## Installation | ||
|
||
To use 2auth, you need to have Python installed on your machine. You can install Python by visiting the [Python website](https://www.python.org) and following the instructions for your operating system. | ||
|
||
After installing Python, you can clone the `2auth` repository to your local machine using the following command: | ||
|
||
```shell | ||
$ git clone https://github.com/pompomdev/2auth.git | ||
``` | ||
|
||
## Usage | ||
|
||
To start using 2auth, navigate to the cloned repository directory in your terminal: | ||
|
||
```shell | ||
$ cd 2auth | ||
``` | ||
|
||
Run the following command to execute the software: | ||
|
||
```shell | ||
$ python main.py | ||
``` | ||
|
||
Once the software is running, you will see a menu with the following options: | ||
|
||
1. Save Entries: Allows you to save authentication entries by providing a name and secret. | ||
2. Generate OTP Codes: Generates OTP codes for the saved authentication entries. | ||
3. Exit: Exits the software. | ||
|
||
Choose an option by entering the corresponding number and following the prompts. Refer to the on-screen instructions for more details on each option. | ||
|
||
## Data Storage | ||
|
||
2auth stores the saved entries in a file named `entries.2auth` in the `data` directory. The entries are serialized using the pickle module. Make sure to back up this file if you intend to switch devices or reinstall the software. | ||
|
||
## Contributing | ||
|
||
Contributions to 2auth are welcome! If you find any issues or have suggestions for improvements, please open a new issue or submit a pull request on the [2auth repository](https://github.com/pompomdev/2auth). | ||
|
||
## License | ||
|
||
This project is licensed under the [Apache 2.0 License](https://opensource.org/licenses/Apache-2.0). Feel free to use, modify, and distribute this software. See the `LICENSE` file for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
- [Security Policy](#security-policy) | ||
- [Supported Versions](#supported-versions) | ||
- [Reporting a Vulnerability](#reporting-a-vulnerability) | ||
|
||
# Security Policy | ||
|
||
## Supported Versions | ||
|
||
We release patches for security vulnerabilities. These are the supported versions: | ||
|
||
| Version | Eligibility | | ||
| --------- | ----------------------------------------- | | ||
| v1.0.0 | :white_check_mark: | | ||
| null | null | | ||
|
||
## Reporting a Vulnerability | ||
|
||
Please report any (suspected) security vulnerabilities to | ||
**[[email protected]]([email protected])**. You will receive a response from | ||
us within around 72 hours. If the issue is confirmed, we will release a patch asap. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import pyotp | ||
import time | ||
import pickle | ||
import os | ||
|
||
def save_entries(): | ||
name = input("Name: ") | ||
secret = input("Secret: ") | ||
|
||
if name and secret: | ||
try: | ||
with open('data/entries.2auth', 'rb') as file: | ||
saved_entries = pickle.load(file) | ||
except FileNotFoundError: | ||
saved_entries = {} | ||
|
||
saved_entries[name] = secret | ||
|
||
os.makedirs('data', exist_ok=True) | ||
|
||
with open('data/entries.2auth', 'wb') as file: | ||
pickle.dump(saved_entries, file) | ||
|
||
print(f"\nEntry for \"{name}\" has been saved successfully.\n") | ||
else: | ||
print("Please fill in all fields correctly.") | ||
|
||
def generate_codes(): | ||
if os.path.exists('data/entries.2auth'): | ||
with open('data/entries.2auth', 'rb') as file: | ||
saved_entries = pickle.load(file) | ||
|
||
if saved_entries: | ||
print("\nExisting Entries:") | ||
print("-----------------") | ||
for entry in saved_entries: | ||
print(entry) | ||
print("-----------------\n") | ||
else: | ||
print("\nNo entries found.\n") | ||
|
||
entries = input("Enter the names of the entries separated by commas (e.g., entry1,entry2): ") | ||
entries = entries.split(',') | ||
|
||
if entries: | ||
otps = {} | ||
entries_not_found = [] | ||
for entry in entries: | ||
if entry in saved_entries: | ||
secret = saved_entries[entry] | ||
otp = pyotp.TOTP(secret) | ||
otps[entry] = otp | ||
else: | ||
entries_not_found.append(entry) | ||
|
||
if entries_not_found: | ||
print(f"\nThe following entries were not found: {', '.join(entries_not_found)}\n") | ||
|
||
if otps: | ||
print("\nGenerating OTP Codes:") | ||
print("---------------------") | ||
while True: | ||
for entry, otp in otps.items(): | ||
code = otp.now() | ||
print(f"The OTP code for \"{entry}\" is: {code}") | ||
print("---------------------") | ||
time.sleep(30) | ||
else: | ||
print("\nNo entries found.\n") | ||
|
||
else: | ||
print("\nNo entries provided.\n") | ||
|
||
else: | ||
print("\nNo saved entries found.\n") | ||
|
||
def print_menu(): | ||
print("2Auth Safer") | ||
print("-----------") | ||
print("1. Save Entries") | ||
print("2. Generate OTP Codes") | ||
print("3. Exit") | ||
|
||
def main(): | ||
while True: | ||
print_menu() | ||
choice = input("Enter your choice (1-3): ") | ||
|
||
if choice == "1": | ||
save_entries() | ||
elif choice == "2": | ||
generate_codes() | ||
elif choice == "3": | ||
print("Exiting...") | ||
break | ||
else: | ||
print("Invalid choice. Please try again.") | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Version: v1.0.0 | ||
Description: First version of the project. | ||
Release Date: Jan 20th | ||
Author: Carlos "pom" Henrique |