8000 GitHub - andycaine/authn-redirector: Lamda@Edge function that redirects clients to a login endpoint if the origin returns a 401 response.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

andycaine/authn-redirector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

authn-redirector

Lamda@Edge function that redirects clients to a login endpoint if the origin returns a 401 response.

Description

When building a web app, we normally want a user that fails authentication checks to be redirected to an authentication screen, rather than be served up a HTTP 401 response. authn-redirector enables this by redirecting an authentication user to an authentication URL if the underlying origin returns a 401 response.

Getting started

authn-redirector is available via the AWS Serverless Application Repository. Include it in your SAM / CloudFormation template as a serverless application, or deploy directly from the AWS Serverless Application Repository.

AuthnRedirector:
  Type: AWS::Serverless::Application
  Properties:
    Location:
      ApplicationId: 'arn:aws:serverlessrepo:eu-west-2:211125310871:applications/authn-redirector'
      SemanticVersion: <CURRENT_VERSION>
    Parameters:
      ...

Note that, as this is a Lambda@Edge resource, it must be deployed in the us-east-1 region.

You can then configure CloudFront to use authn-redirector to perform redirects on 401 responses:

CloudFrontDistro:
  Type: AWS::CloudFront::Distribution
  Properties:
    DistributionConfig:
      DefaultCacheBehavior:
        LambdaFunctionAssociations:
          - EventType: origin-response
            LambdaFunctionARN: !GetAtt AuthnRedirector.Outputs.RedirectorFunctionVersion

About

Lamda@Edge function that redirects clients to a login endpoint if the origin returns a 401 response.

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0