11import logging
22import os
33import urllib3
4+ import webbrowser
45
56from typing import Dict
67from urllib .parse import urlencode
7- from authlib .integrations .base_client import FrameworkIntegration , RemoteApp
8+ from authlib .integrations .base_client import FrameworkIntegration , OAuth2Mixin
89from authlib .integrations .requests_client import OAuth2Session
910
1011from ..configuration import Configuration
2122ACCESS_TOKEN_FIELD = "access_token"
2223
2324
24- class OIDCIntegration (FrameworkIntegration ):
25- oauth2_client_cls = OAuth2Session
26-
27-
2825def _get_token (token : Dict [str , str ]) -> str :
2926 if ID_TOKEN_FIELD not in token :
3027 logger .info (
@@ -43,7 +40,6 @@ def __init__(self, config: Configuration):
4340 super ().__init__ (config )
4441
4542 if not config .verify_ssl :
46- os .environ ["CURL_CA_BUNDLE" ] = ""
4743 urllib3 .disable_warnings (urllib3 .exceptions .InsecureRequestWarning )
4844
4945 if config .oidc_server is None :
@@ -64,13 +60,15 @@ def __init__(self, config: Configuration):
6460
6561 server_metadata_url = f"{ config .oidc_server } /.well-known/openid-configuration"
6662
67- self ._app = RemoteApp (
68- framework = OIDCIntegration ,
63+ self ._app = OAuth2Mixin (
64+ framework = FrameworkIntegration ,
65+ client_kwargs = {"verify" : config .verify_ssl },
6966 client_id = config .oidc_client_id ,
7067 client_secret = config .oidc_client_secret ,
7168 server_metadata_url = server_metadata_url ,
7269 access_token_params = access_token_params ,
7370 )
71+ self ._app .client_cls = OAuth2Session
7472 self ._app .load_server_metadata ()
7573
7674 @_soft_deprecate # type: ignore
@@ -109,10 +107,15 @@ def _use_authorization_code(self):
109107 state = self ._AuthCodeState ,
110108 scope = self ._config .scope ,
111109 )["url" ]
110+
111+ webbrowser .open_new_tab (request_url )
112112 print (
113- "Please copy the following URL into a browser to log in." ,
114- "You will be redirected and shown a code to copy and paste here." ,
115- f"\n \n \t '{ request_url } '\n \n " ,
113+ "The following URL should have opened now on a new tab, where you "
114+ "will be able to log in.\n "
115+ "If it hasn't, please copy the following URL into a browser.\n "
116+ "Once you have logged in, you will be redirected and will be shown a code "
117+ "to copy and paste below."
118+ f"\n \n \t { request_url } \n \n "
116119 )
117120 response_code = self ._get_response_code ()
118121 response_code_query = urlencode ({"code" : response_code })
0 commit comments