impersonationSessionDuration option in admin plugin not working, defaults to 1 day #686

Closed
opened 2026-03-13 08:00:23 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @TariqueAnowar on GitHub (Feb 16, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

Description

The impersonationSessionDuration option in the admin plugin is not being respected. Regardless of the value set, the impersonation session always defaults to 1 day.

Configuration

import { betterAuth } from "better-auth";
import { admin } from "better-auth/plugins";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "./prisma-client";

export const auth = betterAuth({
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
emailAndPassword: {
enabled: true,
},
plugins: [admin({ impersonationSessionDuration: 300 })],
});

Current vs. Expected behavior

Expected Behavior

When setting impersonationSessionDuration: 300, the impersonation session should expire after 5 minutes.

Actual Behavior

The impersonation session always expires after 1 day, ignoring the configured duration.

What version of Better Auth are you using?

1.1.18

Provide environment information

### Environment
- better-auth version: 1.1.18
- Next.js version: 15.1.6
- Database: PostgreSQL with Prisma adapter
- Node.js version: [your Node.js version]

Which area(s) are affected? (Select all that apply)

Backend, Package

Auth config (if applicable)

import { betterAuth } from "better-auth";
import { admin } from "better-auth/plugins";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { prisma } from "./prisma-client";

export const auth = betterAuth({
  database: prismaAdapter(prisma, {
    provider: "postgresql",
  }),
  emailAndPassword: {
    enabled: true,
  },
  plugins: [admin({ impersonationSessionDuration: 300 })],
});

Additional context

Additional Context

  • The issue persists across multiple versions (tested on 1.1.16 through 1.1.18)
  • The session expiration can be verified through the expiresAt field in the session object
Originally created by @TariqueAnowar on GitHub (Feb 16, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce ### Description The `impersonationSessionDuration` option in the admin plugin is not being respected. Regardless of the value set, the impersonation session always defaults to 1 day. ### Configuration import { betterAuth } from "better-auth"; import { admin } from "better-auth/plugins"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { prisma } from "./prisma-client"; export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), emailAndPassword: { enabled: true, }, plugins: [admin({ impersonationSessionDuration: 300 })], }); ### Current vs. Expected behavior ### Expected Behavior When setting `impersonationSessionDuration: 300`, the impersonation session should expire after 5 minutes. ### Actual Behavior The impersonation session always expires after 1 day, ignoring the configured duration. ### What version of Better Auth are you using? 1.1.18 ### Provide environment information ```bash ### Environment - better-auth version: 1.1.18 - Next.js version: 15.1.6 - Database: PostgreSQL with Prisma adapter - Node.js version: [your Node.js version] ``` ### Which area(s) are affected? (Select all that apply) Backend, Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth"; import { admin } from "better-auth/plugins"; import { prismaAdapter } from "better-auth/adapters/prisma"; import { prisma } from "./prisma-client"; export const auth = betterAuth({ database: prismaAdapter(prisma, { provider: "postgresql", }), emailAndPassword: { enabled: true, }, plugins: [admin({ impersonationSessionDuration: 300 })], }); ``` ### Additional context ### Additional Context - The issue persists across multiple versions (tested on 1.1.16 through 1.1.18) - The session expiration can be verified through the `expiresAt` field in the session object
GiteaMirror added the bug label 2026-03-13 08:00:23 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#686