mirror of
https://github.com/PeterMaquiran/tvone.git
synced 2026-04-23 12:35:51 +00:00
simplefy keycloak
This commit is contained in:
@@ -6,30 +6,16 @@ import {
|
|||||||
Settings, HelpCircle, Image as ImageIcon,
|
Settings, HelpCircle, Image as ImageIcon,
|
||||||
Type, Calendar, Clock, Tag, User, Save, Eye, Send
|
Type, Calendar, Clock, Tag, User, Save, Eye, Send
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import Keycloak from "keycloak-js";
|
|
||||||
|
|
||||||
// Importe o componente que criámos (ajuste o caminho se necessário)
|
// Importe o componente que criámos (ajuste o caminho se necessário)
|
||||||
import MultiAspectEditor from '../../components/MultiAspectEditor';
|
import MultiAspectEditor from '../../components/MultiAspectEditor';
|
||||||
import dynamic from "next/dynamic";
|
import dynamic from "next/dynamic";
|
||||||
|
import { keycloak } from '@/app/feature/auth/keycloak-config';
|
||||||
const Editor = dynamic(
|
const Editor = dynamic(
|
||||||
() => import("@tinymce/tinymce-react").then((mod) => mod.Editor),
|
() => import("@tinymce/tinymce-react").then((mod) => mod.Editor),
|
||||||
{ ssr: false }
|
{ ssr: false }
|
||||||
);
|
);
|
||||||
|
|
||||||
const keycloak = new Keycloak({
|
|
||||||
url: "https://keycloak.petermaquiran.xyz",
|
|
||||||
realm: "tvone", // ✅ IMPORTANT
|
|
||||||
clientId: "tvone-web", // must match Keycloak client
|
|
||||||
});
|
|
||||||
|
|
||||||
interface GoogleAuthResponse {
|
|
||||||
access_token: string;
|
|
||||||
token_type: string;
|
|
||||||
expires_in: number;
|
|
||||||
scope: string;
|
|
||||||
authuser?: string;
|
|
||||||
prompt?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface KeycloakTokenResponse {
|
interface KeycloakTokenResponse {
|
||||||
access_token: string;
|
access_token: string;
|
||||||
@@ -131,8 +117,16 @@ const CreateNewsPage = () => {
|
|||||||
|
|
||||||
const profile = await res.json();
|
const profile = await res.json();
|
||||||
|
|
||||||
setUser(profile);
|
var keycloakData : {
|
||||||
console.log("Profile:", profile);
|
email: string,
|
||||||
|
email_verified: boolean,
|
||||||
|
name: string,
|
||||||
|
picture: string,
|
||||||
|
roles: string[]
|
||||||
|
} = profile.keycloak
|
||||||
|
|
||||||
|
setUser(keycloakData);
|
||||||
|
console.log("Profile:", keycloakData);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|||||||
@@ -4,14 +4,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
import { useGoogleLogin } from "@react-oauth/google";
|
import { useGoogleLogin } from "@react-oauth/google";
|
||||||
import { useTheme } from 'next-themes';
|
import { useTheme } from 'next-themes';
|
||||||
import { Sun, Moon } from 'lucide-react'; // Optional: install lucide-react for clean icons
|
import { Sun, Moon } from 'lucide-react'; // Optional: install lucide-react for clean icons
|
||||||
import Keycloak from "keycloak-js";
|
import { keycloak } from '@/app/feature/auth/keycloak-config';
|
||||||
|
|
||||||
|
|
||||||
const keycloak = new Keycloak({
|
|
||||||
url: "https://keycloak.petermaquiran.xyz",
|
|
||||||
realm: "tvone", // ✅ IMPORTANT
|
|
||||||
clientId: "tvone-web", // must match Keycloak client
|
|
||||||
});
|
|
||||||
|
|
||||||
interface GoogleAuthResponse {
|
interface GoogleAuthResponse {
|
||||||
access_token: string;
|
access_token: string;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import Keycloak from "keycloak-js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KEYCLOAK CONFIGURATION
|
* KEYCLOAK CONFIGURATION
|
||||||
* Logic: Environment variable validation and OIDC configuration.
|
* Logic: Environment variable validation and OIDC configuration.
|
||||||
@@ -13,9 +15,15 @@ export const keycloakConfig = {
|
|||||||
|
|
||||||
// Endpoint for global logout
|
// Endpoint for global logout
|
||||||
endSessionEndpoint: `${process.env.KEYCLOAK_ISSUER_URL}/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/logout`,
|
endSessionEndpoint: `${process.env.KEYCLOAK_ISSUER_URL}/realms/${process.env.KEYCLOAK_REALM}/protocol/openid-connect/logout`,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Simple check to ensure environment variables are present
|
// Simple check to ensure environment variables are present
|
||||||
if (!process.env.KEYCLOAK_CLIENT_ID || !process.env.KEYCLOAK_ISSUER_URL) {
|
if (!process.env.KEYCLOAK_CLIENT_ID || !process.env.KEYCLOAK_ISSUER_URL) {
|
||||||
console.warn("Auth Warning: Keycloak environment variables are missing.");
|
console.warn("Auth Warning: Keycloak environment variables are missing.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const keycloak = new Keycloak({
|
||||||
|
url: "https://keycloak.petermaquiran.xyz",
|
||||||
|
realm: "tvone", // ✅ IMPORTANT
|
||||||
|
clientId: "tvone-web", // must match Keycloak client
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user