mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 09:07:02 +02:00
debugging for oidc
This commit is contained in:
parent
d4f1de9073
commit
80ca25339d
3 changed files with 11 additions and 4 deletions
|
@ -27,6 +27,7 @@ class Client(oic.Client):
|
||||||
"""Step 1: Configure the OpenID Connect client."""
|
"""Step 1: Configure the OpenID Connect client."""
|
||||||
logger.debug("Initializing the OpenID Connect client...")
|
logger.debug("Initializing the OpenID Connect client...")
|
||||||
try:
|
try:
|
||||||
|
logger.debug("__init__ first try")
|
||||||
provider = settings.OIDC_PROVIDERS[op]
|
provider = settings.OIDC_PROVIDERS[op]
|
||||||
verify_ssl = getattr(settings, "OIDC_VERIFY_SSL", True)
|
verify_ssl = getattr(settings, "OIDC_VERIFY_SSL", True)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -35,6 +36,7 @@ class Client(oic.Client):
|
||||||
raise o_e.InternalError()
|
raise o_e.InternalError()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug("__init__ second try")
|
||||||
# prepare private key for authentication method of private_key_jwt
|
# prepare private key for authentication method of private_key_jwt
|
||||||
key_bundle = keyio.KeyBundle()
|
key_bundle = keyio.KeyBundle()
|
||||||
rsa_key = importKey(provider["client_registration"]["sp_private_key"])
|
rsa_key = importKey(provider["client_registration"]["sp_private_key"])
|
||||||
|
@ -51,6 +53,7 @@ class Client(oic.Client):
|
||||||
raise o_e.InternalError()
|
raise o_e.InternalError()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug("__init__ third try")
|
||||||
# create the oic client instance
|
# create the oic client instance
|
||||||
super().__init__(
|
super().__init__(
|
||||||
client_id=None,
|
client_id=None,
|
||||||
|
@ -70,6 +73,7 @@ class Client(oic.Client):
|
||||||
raise o_e.InternalError()
|
raise o_e.InternalError()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug("__init__ fourth try")
|
||||||
# discover and store the provider (OP) urls, etc
|
# discover and store the provider (OP) urls, etc
|
||||||
self.provider_config(provider["srv_discovery_url"])
|
self.provider_config(provider["srv_discovery_url"])
|
||||||
self.store_registration_info(RegistrationResponse(**provider["client_registration"]))
|
self.store_registration_info(RegistrationResponse(**provider["client_registration"]))
|
||||||
|
@ -80,6 +84,7 @@ class Client(oic.Client):
|
||||||
provider["srv_discovery_url"],
|
provider["srv_discovery_url"],
|
||||||
)
|
)
|
||||||
raise o_e.InternalError()
|
raise o_e.InternalError()
|
||||||
|
logger.debug("__init__ finished initializing")
|
||||||
|
|
||||||
def create_authn_request(
|
def create_authn_request(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -16,6 +16,7 @@ from registrar.models import User
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
logger.debug("oidc views initializing provider")
|
||||||
# Initialize provider using pyOICD
|
# Initialize provider using pyOICD
|
||||||
OP = getattr(settings, "OIDC_ACTIVE_PROVIDER")
|
OP = getattr(settings, "OIDC_ACTIVE_PROVIDER")
|
||||||
CLIENT = Client(OP)
|
CLIENT = Client(OP)
|
||||||
|
@ -55,7 +56,7 @@ def error_page(request, error):
|
||||||
|
|
||||||
def openid(request):
|
def openid(request):
|
||||||
"""Redirect the user to an authentication provider (OP)."""
|
"""Redirect the user to an authentication provider (OP)."""
|
||||||
|
logger.debug("in openid")
|
||||||
# If the session reset because of a server restart, attempt to login again
|
# If the session reset because of a server restart, attempt to login again
|
||||||
request.session["acr_value"] = CLIENT.get_default_acr_value()
|
request.session["acr_value"] = CLIENT.get_default_acr_value()
|
||||||
|
|
||||||
|
@ -69,6 +70,7 @@ def openid(request):
|
||||||
|
|
||||||
def login_callback(request):
|
def login_callback(request):
|
||||||
"""Analyze the token returned by the authentication provider (OP)."""
|
"""Analyze the token returned by the authentication provider (OP)."""
|
||||||
|
logger.debug("in login_callback")
|
||||||
try:
|
try:
|
||||||
query = parse_qs(request.GET.urlencode())
|
query = parse_qs(request.GET.urlencode())
|
||||||
userinfo = CLIENT.callback(query, request.session)
|
userinfo = CLIENT.callback(query, request.session)
|
||||||
|
|
|
@ -469,19 +469,19 @@ LOGGING = {
|
||||||
# Django's runserver requests
|
# Django's runserver requests
|
||||||
"django.request": {
|
"django.request": {
|
||||||
"handlers": ["django.server"],
|
"handlers": ["django.server"],
|
||||||
"level": "INFO",
|
"level": "DEBUG",
|
||||||
"propagate": False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
# OpenID Connect logger
|
# OpenID Connect logger
|
||||||
"oic": {
|
"oic": {
|
||||||
"handlers": ["console"],
|
"handlers": ["console"],
|
||||||
"level": "INFO",
|
"level": "DEBUG",
|
||||||
"propagate": False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
# Django wrapper for OpenID Connect
|
# Django wrapper for OpenID Connect
|
||||||
"djangooidc": {
|
"djangooidc": {
|
||||||
"handlers": ["console"],
|
"handlers": ["console"],
|
||||||
"level": "INFO",
|
"level": "DEBUG",
|
||||||
"propagate": False,
|
"propagate": False,
|
||||||
},
|
},
|
||||||
# Our app!
|
# Our app!
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue