Skip to content

Commit

Permalink
Merge pull request #130 from forza-mor-rotterdam/remove-ua-from-requests
Browse files Browse the repository at this point in the history
#MOR-15: remove user agent from python requests
  • Loading branch information
mguikema authored Sep 23, 2024
2 parents 41a38b9 + d64965f commit 0595103
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 81 deletions.
32 changes: 0 additions & 32 deletions app/apps/authenticatie/views.py

This file was deleted.

5 changes: 4 additions & 1 deletion app/apps/services/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from urllib.parse import urlencode

import requests
import urllib3
from django.core.cache import cache
from requests import Request, Response

Expand Down Expand Up @@ -29,7 +30,9 @@ def get_url(self, url):
return url

def get_headers(self):
return {}
return {
"user-agent": urllib3.util.SKIP_HEADER,
}

def naar_json(self, response):
try:
Expand Down
9 changes: 8 additions & 1 deletion app/apps/services/meldingen.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from urllib.parse import urlparse

import requests
import urllib3
from django.conf import settings
from django.core.cache import cache
from django.core.exceptions import ValidationError
Expand Down Expand Up @@ -77,6 +78,9 @@ def haal_token(self):
"username": email,
"password": settings.MELDINGEN_PASSWORD,
},
headers={
"user-agent": urllib3.util.SKIP_HEADER,
},
)
if token_response.status_code == 200:
meldingen_token = token_response.json().get("token")
Expand All @@ -91,7 +95,10 @@ def haal_token(self):
return meldingen_token

def get_headers(self):
headers = {"Authorization": f"Token {self.haal_token()}"}
headers = {
"user-agent": urllib3.util.SKIP_HEADER,
"Authorization": f"Token {self.haal_token()}",
}
return headers

def do_request(self, url, method="get", data={}, raw_response=True, stream=False):
Expand Down
9 changes: 7 additions & 2 deletions app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from os.path import join

import requests
import urllib3

locale.setlocale(locale.LC_ALL, "nl_NL.UTF-8")
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -363,7 +364,12 @@
)
OPENID_CONFIG = {}
try:
OPENID_CONFIG = requests.get(OPENID_CONFIG_URI).json()
OPENID_CONFIG = requests.get(
OPENID_CONFIG_URI,
headers={
"user-agent": urllib3.util.SKIP_HEADER,
},
).json()
except Exception as e:
logger.error(f"OPENID_CONFIG FOUT, url: {OPENID_CONFIG_URI}, error: {e}")

Expand Down Expand Up @@ -402,7 +408,6 @@
"apps.authenticatie.auth.OIDCAuthenticationBackend",
]

OIDC_OP_LOGOUT_URL_METHOD = "apps.authentication.views.provider_logout"
ALLOW_LOGOUT_GET_METHOD = True
OIDC_STORE_ID_TOKEN = True
OIDC_RENEW_ID_TOKEN_EXPIRY_SECONDS = int(
Expand Down
45 changes: 0 additions & 45 deletions app/config/webpack.py

This file was deleted.

0 comments on commit 0595103

Please sign in to comment.