Implement cookie authentication
This commit is contained in:
parent
a2976cdcc2
commit
6ff20ca605
@ -1,9 +1,10 @@
|
||||
import enum
|
||||
|
||||
import browser_cookie3
|
||||
from loguru import logger
|
||||
from requests import Session
|
||||
|
||||
from fime.config import Config, AuthMethods
|
||||
from fime.config import Config, AuthMethods, Browsers
|
||||
|
||||
try:
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
@ -61,6 +62,21 @@ def add_auth(config: Config, session: Session):
|
||||
case AuthMethods.TOKEN:
|
||||
session.headers["Authorization"] = f"Bearer {config.jira_token}"
|
||||
case AuthMethods.COOKIES:
|
||||
raise NotImplemented
|
||||
match config.cookie_source:
|
||||
case Browsers.AUTO:
|
||||
cookie_jar = browser_cookie3.load()
|
||||
case Browsers.FIREFOX:
|
||||
cookie_jar = browser_cookie3.firefox()
|
||||
case Browsers.CHROME:
|
||||
cookie_jar = browser_cookie3.chrome()
|
||||
case Browsers.CHROMIUM:
|
||||
cookie_jar = browser_cookie3.chromium()
|
||||
case Browsers.EDGE:
|
||||
cookie_jar = browser_cookie3.edge()
|
||||
case Browsers.OPERA:
|
||||
cookie_jar = browser_cookie3.opera()
|
||||
case _:
|
||||
raise AssertionError("Unknown cookie_source")
|
||||
session.cookies = cookie_jar
|
||||
case _:
|
||||
raise AssertionError("Unknown auth method")
|
||||
|
Loading…
Reference in New Issue
Block a user