Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2FA currently not supported on docker #123

Open
Disane87 opened this issue Jul 5, 2023 · 7 comments
Open

2FA currently not supported on docker #123

Disane87 opened this issue Jul 5, 2023 · 7 comments
Labels
docker Docker related issues information known issue This issue is known bug

Comments

@Disane87
Copy link
Owner

Disane87 commented Jul 5, 2023

Currently 2FA of the scraped pages are not supported. Actually it's detected (i.e. for amazon) but there is no way to set it within a docker container

@Disane87 Disane87 added information known issue This issue is known bug labels Jul 5, 2023
@Disane87 Disane87 pinned this issue Jul 5, 2023
@Disane87 Disane87 added the docker Docker related issues label Jul 11, 2023
@Disane87 Disane87 changed the title 2FA not currently supported on docker 2FA currently not supported on docker Mar 7, 2024
@soonic6
Copy link

soonic6 commented Mar 20, 2024

will 2fa support be added? i am planing using and releasing it on unraid?

@Disane87
Copy link
Owner Author

Disane87 commented Mar 20, 2024

In the future I guess yes. But I don't have any idea how to reliable implement this. Additionally it should work more or less unattended or only the with a convenient way to obtain/set the 2fa code

@tlwt
Copy link

tlwt commented Jun 15, 2024

To streamline the process of retrieving one-time passwords (OTPs) for Amazon, I propose adding a variable AMAZON_OTP to the Docker call. This variable can be utilized in calls requiring OTPs. Modern password managers, such as 1Password, allow automatic retrieval of OTPs via their CLI. Below is an example script (tested on MacOS) demonstrating how to achieve this with 1Password. Similar methods should work with other password managers.

OTPs are typically valid for 30 seconds, starting at the beginning of each minute and at the 30-second mark. The threshold ensures there is enough time remaining to process the login.

#!/bin/bash

# Set the threshold time, below which a new OTP should be fetched
threshold=10

# Function to calculate the remaining time
get_time_remaining() {
  # Get the current time in seconds since Unix epoch
  current_time=$(date +%s)
  
  # Calculate the number of seconds since Unix epoch modulo 30
  echo $((30 - current_time % 30))
}

# Initially fetch the remaining time
time_remaining=$(get_time_remaining)

# Check if the remaining time is below the threshold
if [ $time_remaining -le $threshold ]; then
  echo "The remaining validity time is $time_remaining seconds. Waiting for a new OTP..."
  
  # Countdown
  while [ $time_remaining -gt 0 ]; do
    echo "Waiting: $time_remaining seconds"
    sleep 1
    time_remaining=$((time_remaining - 1))
  done
fi

# Fetch the current OTP after the wait time has elapsed
otp_value=$(/usr/local/bin/op item get "amazon.de" --vault "Private" --otp)

# Recalculate the remaining time
time_remaining=$(get_time_remaining)

echo "Current OTP: $otp_value"
echo "Remaining validity time: $time_remaining seconds"

@Disane87
Copy link
Owner Author

Disane87 commented Jun 15, 2024

Wow, that looks interesting. Will digg into that if I got some spare time. @tlwt thank you for this great proposal

@Disane87
Copy link
Owner Author

How will this work with unattended servers running that approach with OTP? I have an unraid server and that container runs completely off from any personal password/2fa managers.

As far as I understand your proposal needs a 2fa manager in access locally. But that isn't the case when you run it like in my use case.

If you run it completely on your computers docker I guess the non approach would be better since I could print for the otp, grab that and fill that into the otp field.

Any ideas?

@tlwt
Copy link

tlwt commented Jun 17, 2024

This workaround is intended for a local environment and is not suitable for servers.

Two-factor authentication (2FA) or multi-factor authentication (MFA) requires you to know, have, or be something. App passwords can sometimes be used as an alternative, but to my knowledge, Amazon.de does not offer app passwords or API access to invoices.

In theory, you could store the OTP secret within the app, allowing for on-the-fly generation of OTPs. However, this would defeat the purpose of multi-factor authentication, as both factors would be “knowledge” based and stored in one location.

A much better approach, specific to 1Password, is setting up a 1Password Connect server (https://developer.1password.com/docs/connect/get-started/).

Please note, I am not a security expert; I am simply sharing my thoughts on the matter.

@tlwt
Copy link

tlwt commented Aug 23, 2024

To further enhance this approach:

You can launch the Docker container with an interactive terminal using the -it option. The example below retrieves the username and password from 1Password and passes them to the Docker container:

amazon_email=$(op item get "amazon.de" --fields email) && \
amazon_password=$(op item get "amazon.de" --fields password) && \
docker run --rm --platform linux/amd64 \
-e DEBUG=true \
-e AMAZON_USER=$amazon_email \
-e AMAZON_PASSWORD=$amazon_password \
-v "$(PWD)/docudigger:/home/node/docudigger" \
-it ghcr.io/disane87/docudigger /bin/bash

Once inside the container, run the following command:

docudigger scrape amazon -u $AMAZON_USER -p $AMAZON_PASSWORD --yearFilter=2024 --onlyNew

You'll be prompted for the OTP, which needs to be entered manually. I’ve attempted to automate this using methods like | piping and expect, but haven’t succeeded. If you have other ideas, they would be welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docker Docker related issues information known issue This issue is known bug
Projects
None yet
Development

No branches or pull requests

3 participants