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

Update justice auth flow to use client_secret and prompt login #1282

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions controlpanel/frontend/views/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Third-party
import sentry_sdk
import structlog
from authlib.integrations.django_client import OAuthError
from django.conf import settings
from django.contrib import messages
Expand All @@ -12,6 +13,8 @@
# First-party/Local
from controlpanel.oidc import OIDCLoginRequiredMixin, oauth

log = structlog.getLogger(__name__)


class EntraIdAuthView(OIDCLoginRequiredMixin, View):
"""
Expand All @@ -28,6 +31,7 @@ def _get_access_token(self):
token = oauth.azure.authorize_access_token(self.request)
except OAuthError as error:
sentry_sdk.capture_exception(error)
log.error(error.description)
token = None
return token

Expand Down
5 changes: 3 additions & 2 deletions controlpanel/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,14 @@
AUTHLIB_OAUTH_CLIENTS = {
"azure": {
"client_id": os.environ.get("AZURE_CLIENT_ID"),
# TODO client_secret is not strictly required but would be better to use
"client_secret": os.environ.get("AZURE_CLIENT_SECRET"),
"server_metadata_url": AZURE_OP_CONF_URL,
"client_kwargs": {
"scope": AZURE_RP_SCOPES,
"response_type": "code",
"token_endpoint_auth_method": "none",
"token_endpoint_auth_method": "client_secret_post",
"code_challenge_method": AZURE_CODE_CHALLENGE_METHOD,
"prompt": "login"
},

}
Expand Down
Loading