~sircmpwn/public-inbox

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH pass-rotate] Add Codeberg.org Provider

Details
Message ID
<20211018051657.2548-1-pranjal.kole7@gmail.com>
DKIM signature
pass
Download raw message
Patch: +43 -0
2FA support for Codeberg not implemented in this commit.
Codeberg uses a per-session hidden input element as a CSRF token.
---
 passrotate/providers/__init__.py |  1 +
 passrotate/providers/codeberg.py | 42 ++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)
 create mode 100644 passrotate/providers/codeberg.py

diff --git a/passrotate/providers/__init__.py b/passrotate/providers/__init__.py
index df190ef..74e1eb0 100644
--- a/passrotate/providers/__init__.py
+++ b/passrotate/providers/__init__.py
@@ -16,3 +16,4 @@ from passrotate.providers.gitlab import GitLab
from passrotate.providers.wikipedia import Wikipedia
from passrotate.providers.aur import ArchUserRepository
from passrotate.providers.lichess import Lichess
from passrotate.providers.codeberg import Codeberg
diff --git a/passrotate/providers/codeberg.py b/passrotate/providers/codeberg.py
new file mode 100644
index 0000000..06a86f9
--- /dev/null
+++ b/passrotate/providers/codeberg.py
@@ -0,0 +1,42 @@
from passrotate.provider import Provider, ProviderOption, register_provider
from passrotate.forms import get_form
import requests

class Codeberg(Provider):
    """
    [codeberg.org]
    username=Your Codeberg.org username
    """
    name = "Codeberg"
    domains = [
        "codeberg.org",
    ]
    options = {
        "username": ProviderOption(str, "Your Codeberg username")
    }

    def __init__(self, options):
        self.username = options["username"]

    def prepare(self, old_password):
        self._session = requests.Session()
        login_url = "https://codeberg.org/user/login"
        login_form = {
            "user_name": self.username,
            "password": old_password
        }
        self._session.post(login_url, data=login_form)

    def execute(self, old_password, new_password):
        password_change_url = "https://codeberg.org/user/settings/account"
        password_change_form = get_form(self._session.get(password_change_url).text)

        password_change_form.update({
            "old_password": old_password,
            "password": new_password,
            "retype": new_password
        })

        self._session.post(password_change_url, data=password_change_form)

register_provider(Codeberg)
-- 
2.33.1
Details
Message ID
<CF2E34KCDJY3.13KBBB7C5X54S@taiga>
In-Reply-To
<20211018051657.2548-1-pranjal.kole7@gmail.com> (view parent)
DKIM signature
fail
Download raw message
DKIM signature: fail
Thanks!

To git@git.sr.ht:~sircmpwn/pass-rotate
   f99817e..e518b97  master -> master
Reply to thread Export thread (mbox)