Skip to content

Add headers for local strategy in SignIn #880

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

Closed
2 of 5 tasks
dangercris opened this issue Aug 23, 2024 · 1 comment · Fixed by #881
Closed
2 of 5 tasks

Add headers for local strategy in SignIn #880

dangercris opened this issue Aug 23, 2024 · 1 comment · Fixed by #881
Labels
enhancement An improvement that needs to be added

Comments

@dangercris
Copy link
Contributor

Describe the feature

We need to enhance the sign-in functionality to support custom headers in the login request. Currently, the headers parameter (signInHeaders) is optional and defaults to an empty object if not provided. However, we require the ability to pass specific headers during the sign-in process, which might be necessary for various use cases like API versioning, custom authentication tokens, or additional security measures.

const signIn: SignInFunc<Credentials, any> = async (credentials, signInOptions, signInParams) => {
  const nuxt = useNuxtApp()

  const runtimeConfig = await callWithNuxt(nuxt, useRuntimeConfig)
  const config = useTypedBackendConfig(runtimeConfig, 'local')
  const { path, method } = config.endpoints.signIn
  const response = await _fetch<Record<string, any>>(nuxt, path, {
    method,
    body: credentials,
    params: signInParams ?? {}
  })
}

How would you implement this?

Proposed Changes

  • Add Custom Headers: Ensure that custom headers can be passed into the signInHeaders parameter and included in the request. This will allow more flexibility for the client-side application to communicate with the backend.
  • Documentation: Update the documentation to reflect the inclusion of custom headers, including examples of how to use them effectively.
  • Testing: Implement unit and integration tests to verify that the headers are correctly passed and processed during the sign-in request.

Benefits

  • Flexibility: Enables the passing of custom headers, which can be crucial for meeting specific security and configuration requirements.
  • Scalability: Improves the scalability of the sign-in mechanism by allowing additional customization points without altering the core functionality.
  • Security: Supports the implementation of advanced security features by allowing headers to carry necessary authentication or verification tokens.

Additional information

  • Would you be willing to help implement this feature?

Provider

  • AuthJS
  • Local
  • Refresh
  • New Provider
@dangercris dangercris added enhancement An improvement that needs to be added pending An issue waiting for triage labels Aug 23, 2024
@zoey-kaiser zoey-kaiser removed the pending An issue waiting for triage label Aug 25, 2024
zoey-kaiser added a commit that referenced this issue Aug 25, 2024
@zoey-kaiser
Copy link
Member

Released in @sidebase/[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement that needs to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants