feat: implement session lifetimes

This commit is contained in:
Max Peintner
2024-11-27 11:02:34 +01:00
parent dae8b28597
commit 9573cdba04
7 changed files with 93 additions and 64 deletions

View File

@@ -18,7 +18,7 @@ import {
VerifyU2FRegistrationRequest,
} from "@zitadel/proto/zitadel/user/v2/user_service_pb";
import { create } from "@zitadel/client";
import { create, Duration } from "@zitadel/client";
import { TextQueryMethod } from "@zitadel/proto/zitadel/object/v2/object_pb";
import { CreateCallbackRequest } from "@zitadel/proto/zitadel/oidc/v2/oidc_service_pb";
import { Organization } from "@zitadel/proto/zitadel/org/v2/org_pb";
@@ -132,15 +132,13 @@ export async function getPasswordComplexitySettings(organization?: string) {
export async function createSessionFromChecks(
checks: Checks,
challenges: RequestChallenges | undefined,
lifetime?: Duration,
) {
return sessionService.createSession(
{
checks: checks,
challenges,
lifetime: {
seconds: BigInt(SESSION_LIFETIME_S),
nanos: 0,
},
lifetime,
},
{},
);
@@ -152,6 +150,7 @@ export async function createSessionForUserIdAndIdpIntent(
idpIntentId?: string | undefined;
idpIntentToken?: string | undefined;
},
lifetime?: Duration,
) {
return sessionService.createSession({
checks: {
@@ -163,10 +162,7 @@ export async function createSessionForUserIdAndIdpIntent(
},
idpIntent,
},
// lifetime: {
// seconds: 300,
// nanos: 0,
// },
lifetime,
});
}
@@ -175,6 +171,7 @@ export async function setSession(
sessionToken: string,
challenges: RequestChallenges | undefined,
checks?: Checks,
lifetime?: Duration,
) {
return sessionService.setSession(
{
@@ -183,6 +180,7 @@ export async function setSession(
challenges,
checks: checks ? checks : {},
metadata: {},
lifetime,
},
{},
);