Skip to content

Commit

Permalink
Update authn.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zcqian committed Nov 19, 2021
1 parent bc799ad commit 5335478
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion biothings/web/auth/authn.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ def get_current_user(self) -> Optional[dict]:
"""
raise NotImplementedError

def get_authenticate_header(self) -> Optional[str]:
"""
Return a string used for the 'WWW-Authenticate' Header
If the handler returns a 401, this is used
"""
# FIXME: need to figure out a way to support both Authorization header
# and non-authorization header methods
# the former should return a 401 and will need WWW-Authenticate
# while the latter (say cookie based) gets more freedom.
return None


class BioThingsAuthnMixin(BaseHandler):
def get_current_user(self):
Expand All @@ -37,7 +49,11 @@ def get_current_user(self):
# Compare to PAM in Linux. Sample logic below
authenticators: \
Iterable[Tuple[Type[BioThingsAuthenticationProviderInterface], dict], ...] = \
self.biothings.config.AUTHN_PROVIDERS
getattr(
self,
'AUTHN_PROVIDERS',
self.biothings.config.AUTHN_PROVIDERS
)

# loop through the list in order and initialize the provider using
# self & configured options (like how handlers are configured for routing)
Expand Down

0 comments on commit 5335478

Please sign in to comment.