11
11
logger = logging .getLogger (__name__ )
12
12
13
13
14
- class PalletAuth (WebFrameworkAuth ): # A common base class for Flask and Quart
14
+ class PalletAuth (WebFrameworkAuth ):
15
+ """A common base class for Flask and Quart web authentication.
16
+
17
+ Provides shared functionality for login handling, session management, and routing
18
+ used by both Flask and Quart framework implementations.
19
+ """
15
20
_endpoint_prefix = "identity" # A convention to match the template's folder name
16
21
_auth : Optional [Auth ] = None # None means not initialized yet
17
22
18
- def __init__ (self , app , * args , ** kwargs ):
23
+ def __init__ (self , app , * args , prompt : Optional [str ] = None , ** kwargs ):
24
+ """Initialize the Auth class for a Pallet-based web application.
25
+
26
+ :param app:
27
+ The Flask or Quart application instance, or ``None``.
28
+ If None, you must call init_app() later. This pattern can be useful
29
+ when your project does not use a global app object, such as when using
30
+ the application factory pattern.
31
+ :param str prompt:
32
+ Optional. The prompt parameter to be used during login.
33
+ Valid values are defined in
34
+ `OpenID Connect Core spec <https://openid.net/specs/openid-connect-core-1_0.html#AuthRequest>`_
35
+ """
19
36
if not (
20
37
self ._Blueprint and self ._Session and self ._redirect
21
38
and getattr (self , "_session" , None ) is not None
@@ -24,6 +41,7 @@ def __init__(self, app, *args, **kwargs):
24
41
raise RuntimeError (
25
42
"Subclass must provide "
26
43
"_Blueprint, _Session, _redirect, _session, and _request." )
44
+ self ._prompt = prompt
27
45
super (PalletAuth , self ).__init__ (* args , ** kwargs )
28
46
self ._bp = bp = self ._Blueprint (
29
47
self ._endpoint_prefix ,
@@ -106,4 +124,3 @@ def wrapper(*args, **kwargs):
106
124
# Save an http 302 by calling self.login(request) instead of redirect(self.login)
107
125
return self .login (next_link = self ._request .url , scopes = scopes )
108
126
return wrapper
109
-
0 commit comments