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

custom cookie name for local provider #717

Closed
2 of 5 tasks
GamerGirlandCo opened this issue Mar 21, 2024 · 3 comments
Closed
2 of 5 tasks

custom cookie name for local provider #717

GamerGirlandCo opened this issue Mar 21, 2024 · 3 comments
Labels
enhancement An improvement that needs to be added p2 Nice to have provider-local An issue with the local provider

Comments

@GamerGirlandCo
Copy link

Describe the feature

I'd like the ability to change the name of the cookie that stores the local provider's token.

How would you implement this?

through an option in the nuxt config

Additional information

  • Would you be willing to help implement this feature?

Provider

  • AuthJS
  • Local
  • Refresh
  • New Provider
@GamerGirlandCo GamerGirlandCo added enhancement An improvement that needs to be added pending An issue waiting for triage labels Mar 21, 2024
@zoey-kaiser zoey-kaiser added p2 Nice to have provider-local An issue with the local provider and removed pending An issue waiting for triage labels Mar 30, 2024
@zoey-kaiser
Copy link
Member

Hi @GamerGirlandCo 👋

Thanks for the suggestion. I think configuring it via the Nuxt Config makes sense. Would you like to open a PR yourself?

@GamerGirlandCo
Copy link
Author

Hi @GamerGirlandCo 👋

Thanks for the suggestion. I think configuring it via the Nuxt Config makes sense. Would you like to open a PR yourself?

I was going to, but looking at the code, it appears that it's already been done here 😅

export type ProviderLocal = {
/**
* Uses the `local` provider to facilitate authentication. Currently, two providers exclusive are supported:
* - `authjs`: `next-auth` / `auth.js` based OAuth, Magic URL, Credential provider for non-static applications
* - `local` or 'refresh': Username and password provider with support for static-applications
*
* Read more here: https://sidebase.io/nuxt-auth/v0.6/getting-started
*/
type: Extract<SupportedAuthProviders, 'local'>;
/**
* Endpoints to use for the different methods. `nuxt-auth` will use this and the root-level `baseURL` to create the final request. E.g.:
* - `baseURL=/api/auth`, `path=/login` will result in a request to `/api/auth/login`
* - `baseURL=http://localhost:5000/_authenticate`, `path=/sign-in` will result in a request to `http://localhost:5000/_authenticate/sign-in`
*/
endpoints?: {
/**
* What method and path to call to perform the sign-in. This endpoint must return a token that can be used to authenticate subsequent requests.
*
* @default { path: '/login', method: 'post' }
*/
signIn?: { path?: string; method?: RouterMethod };
/**
* What method and path to call to perform the sign-out. Set to false to disable.
*
* @default { path: '/logout', method: 'post' }
*/
signOut?: { path?: string; method?: RouterMethod } | false;
/**
* What method and path to call to perform the sign-up.
*
* @default { path: '/register', method: 'post' }
*/
signUp?: { path?: string; method?: RouterMethod };
/**
* What method and path to call to fetch user / session data from. `nuxt-auth` will send the token received upon sign-in as a header along this request to authenticate.
*
* Refer to the `token` configuration to configure how `nuxt-auth` uses the token in this request. By default it will be send as a bearer-authentication header like so: `Authentication: Bearer eyNDSNJDASNMDSA....`
*
* @default { path: '/session', method: 'get' }
* @example { path: '/user', method: 'get' }
*/
getSession?: { path?: string; method?: RouterMethod };
};
/**
* Pages that `nuxt-auth` needs to know the location off for redirects.
*/
pages?: {
/**
* Path of the login-page that the user should be redirected to, when they try to access a protected page without being logged in.
*
* @default '/login'
*/
login?: string;
};
/**
* Settings for the authentication-token that `nuxt-auth` receives from the `signIn` endpoint and that can be used to authenticate subsequent requests.
*/
token?: {
/**
* How to extract the authentication-token from the sign-in response.
*
* E.g., setting this to `/token/bearer` and returning an object like `{ token: { bearer: 'THE_AUTH_TOKEN' }, timestamp: '2023' }` from the `signIn` endpoint will
* result in `nuxt-auth` extracting and storing `THE_AUTH_TOKEN`.
*
* This follows the JSON Pointer standard, see it's RFC6901 here: https://www.rfc-editor.org/rfc/rfc6901
*
* @default /token Access the `token` property of the sign-in response object
* @example / Access the root of the sign-in response object, useful when your endpoint returns a plain, non-object string as the token
*/
signInResponseTokenPointer?: string;
/**
* Header type to be used in requests. This in combination with `headerName` is used to construct the final authentication-header `nuxt-auth` uses, e.g, for requests via `getSession`.
*
* @default Bearer
* @example Beer
*/
type?: string;
/**
* It refers to the name of the property when it is stored in a cookie.
*
* @default auth.token
* @example auth._token
*/
cookieName?: string;
/**
* Header name to be used in requests that need to be authenticated, e.g., to be used in the `getSession` request.
*
* @default Authorization
* @example Auth
*/
headerName?: string;
/**
* Maximum age to store the authentication token for. After the expiry time the token is automatically deleted on the application side, i.e., in the users' browser.
*
* Note: Your backend may reject / expire the token earlier / differently.
* @default 1800
* @example 60 * 60 * 24
*/
maxAgeInSeconds?: number;
/**
* The cookie sameSite policy. See the specification here: https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-03#section-4.1.2.7
*
* @default 'lax'
* @example 'strict'
*/
sameSiteAttribute?: boolean | 'lax' | 'strict' | 'none' | undefined;
};
/**
* Define an interface for the session data object that `nuxt-auth` expects to receive from the `getSession` endpoint.
*
* @default { id: 'string | number' }
* @example { id: 'string', name: 'string', email: 'string' }
* @advanced_array_example { id: 'string', email: 'string', name: 'string', role: 'admin | guest | account', subscriptions: "{ id: number, status: 'ACTIVE' | 'INACTIVE' }[]" }
*/
sessionDataType?: SessionDataObject;
};

@phoenix-ru
Copy link
Collaborator

Was already closed by #654

@phoenix-ru phoenix-ru closed this as not planned Won't fix, can't repro, duplicate, stale Apr 25, 2024
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 p2 Nice to have provider-local An issue with the local provider
Projects
None yet
Development

No branches or pull requests

3 participants