Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: provide a custom error message or redirect #1

Closed
atinux opened this issue Jul 6, 2021 — with Volta.net · 4 comments
Closed

feat: provide a custom error message or redirect #1

atinux opened this issue Jul 6, 2021 — with Volta.net · 4 comments
Labels
enhancement New feature or request

Comments

Copy link
Contributor

atinux commented Jul 6, 2021

I like the simple redirect of passport.js.

passport.authenticate('local', {
  successRedirect: '/',
  failureRedirect: '/login'
})
@atinux atinux added the enhancement New feature or request label Jul 6, 2021 — with Volta.net
Copy link
Contributor Author

atinux commented Jul 6, 2021

I also like the API of having first param for provider:

From:

createAuthMiddleware({
  provider: 'basic',
  providerOptions: { username: 'test', password: 'test' }
})

To:

createAuthMiddleware('basic', {
  username: 'test',
  password: 'test'
})

@pi0
Copy link
Contributor

pi0 commented Jul 6, 2021

Dealing with redirects might start to make usage tricky since goal of this package is to secure pages in simplest possible way not a full featured authentication system that passport provides. (there is no login page. Every route matching middleware needs auth)

@atinux
Copy link
Contributor Author

atinux commented Jul 6, 2021

Yes I fully agree on the simplicity of it.

Could we at least give a way to the user a way to render a specific response (ex: rendering a HTML document to explain why he does not have access)

createAuthMiddleware({
  enabled: process.env.NODE_ENV === 'production',
  provider: 'github',
  providerOptions: {
    clientId: 'id',
    clientSecret: 'secret'
  },
  sessionSecret: 'secret',
  message: fs.readFileSync('error.html')
})

@pi0 pi0 closed this as completed in 1a26c00 Jul 7, 2021
pi0 added a commit that referenced this issue Jul 7, 2021
@pi0
Copy link
Contributor

pi0 commented Jul 7, 2021

  • Added support for unauthorizedTemplate
  • Provider options are now flattened

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants