UNPKG

ssr-keycloak

Version:

SSR compatible Keycloak authentication library for React applications

46 lines (45 loc) 1.91 kB
import { KeycloakSession, KeycloakRequestContext, KeycloakResponseContext } from '../types'; /** * Request'ten session'ı okur */ export declare function getSessionFromRequest(request: KeycloakRequestContext): KeycloakSession | null; /** * Session'ı response'a yazar */ export declare function setSessionInResponse(session: KeycloakSession, response: KeycloakResponseContext): void; /** * Session'ı response'dan siler */ export declare function clearSessionInResponse(response: KeycloakResponseContext): void; /** * Session'ın geçerli olup olmadığını kontrol eder */ export declare function isSessionValid(session: KeycloakSession | null): boolean; /** * Session'ı yeniler (lastActivity günceller) */ export declare function refreshSession(session: KeycloakSession): KeycloakSession; /** * Yeni session oluşturur */ export declare function createNewSession(userId: string, tokens: any, user: any, realm: string, clientId: string, expiresIn?: number): KeycloakSession; /** * Session'ı günceller */ export declare function updateSession(currentSession: KeycloakSession, updates: Partial<KeycloakSession>): KeycloakSession; /** * Session'dan kullanıcı rollerini alır */ export declare function getUserRolesFromSession(session: KeycloakSession | null, resource?: string): string[]; /** * Session'da belirli bir rol olup olmadığını kontrol eder */ export declare function hasRoleInSession(session: KeycloakSession | null, role: string, resource?: string): boolean; /** * Session'da belirli rollerden herhangi biri olup olmadığını kontrol eder */ export declare function hasAnyRoleInSession(session: KeycloakSession | null, roles: string[], resource?: string): boolean; /** * Session'da belirli rollerin hepsinin olup olmadığını kontrol eder */ export declare function hasAllRolesInSession(session: KeycloakSession | null, roles: string[], resource?: string): boolean;