Skip to content

feat: app registration authentication for equnor pi webapi - #472

Open
asmfstatoil wants to merge 4 commits into
mainfrom
radix_preparation
Open

feat: app registration authentication for equnor pi webapi#472
asmfstatoil wants to merge 4 commits into
mainfrom
radix_preparation

Conversation

@asmfstatoil

Copy link
Copy Markdown
Collaborator

No description provided.

@asmfstatoil

Copy link
Copy Markdown
CollaboratorAuthor

Arbeider med PI-teamet for å få autentisering til å virke med app-registrering. Kan hende det vert endring i client app-id

@asmfstatoil
asmfstatoil marked this pull request as draft May 12, 2026 13:56
@asmfstatoil
asmfstatoilforce-pushed the radix_preparation branch 2 times, most recently from 0d53c2f to 5024deaCompareJune 23, 2026 22:32
@asmfstatoil
asmfstatoil marked this pull request as ready for review August 18, 2026 13:39
@asmfstatoil
asmfstatoil requested a balanced review from CopilotAugust 18, 2026 13:40

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 8 changed files in this pull request and generated no new comments.

Suppressed comments (6)

tagreader/web_handlers.py:86

  • http.cookiejar.Cookie cannot be constructed with only name/value/domain/... keyword args; the constructor requires many required fields (e.g., version, port, domain_specified, etc.). This will raise TypeError when converting Playwright cookies. Consider building a requests.cookies.RequestsCookieJar and using .set(...) instead.
def browser_context_to_cookiejar(
context: BrowserContext, domain_filter: Optional[str] = None
):
"""Convert Playwright browser context cookies to a Requests cookie jar."""
cookie_jar = CookieJar()

tagreader/web_handlers.py:167

  • Launching Playwright with channel="msedge" unconditionally is Windows/Edge-specific and will fail on macOS/Linux. Gate the channel selection by platform (or omit channel outside Windows) to keep the fallback auth path from crashing on non-Windows hosts.
 with sync_playwright() as playwright:
browser = playwright.chromium.launch(headless=False, channel="msedge")

tagreader/web_handlers.py:71

  • browser_cookie3.edge() returns a CookieJar that doesn't support len(), so len(cookies) == 0 will raise TypeError at runtime. Convert the jar to a list (or use any(...)) before checking emptiness.

This issue also appears on line 82 of the same file.

def f5_check_browser_cookie():
cookies = browser_cookie3.edge(domain_name=".equinor.com")
if len(cookies) == 0:
raise ConnectionError(
"No cookies found for .piwebapi.equinor.com. Please log in to the F5 VPN using Microsoft Edge and try again."

tagreader/web_handlers.py:163

  • STATE_FILE is written to the current working directory, which can be read-only (services/containers) and is easy to accidentally leak even with .gitignore. Store it under a user-scoped directory and ensure it exists.

This issue also appears on line 166 of the same file.

def ensure_f5_authenticated_context():
STATE_FILE = Path(f"f5_{get_user_name()}_piwebapi_session.json")

tagreader/web_handlers.py:199

  • get_auth_pi() can return cookie-based auth objects (Cookie/CookieJar/list of cookie dicts), but the return annotation only includes HTTPKerberosAuth and BearerAuth. This is now incorrect and makes downstream typing misleading.
def get_auth_pi(use_internal: bool = True) -> Union[HTTPKerberosAuth, BearerAuth]:

tagreader/web_handlers.py:357

  • On JSON decode failure this function returns [], but callers treat the result as a dict (e.g., ...webid_dict()[datasource]), which will raise TypeError. Return {} instead. (Also, the function’s return annotation currently indicates a list; it should match the dict returned on the success path.)
 return []

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@asmfstatoil