Skip to content

Commit

Permalink
fix oidc redirect; fix base url in config
Browse files Browse the repository at this point in the history
  • Loading branch information
moeakwak committed Apr 6, 2024
1 parent 39c6b9c commit 5fdef6c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ ENABLE_PASSWORD_LOGIN=true

# site
SITE_NAME="Easy Panel"
BASE_URL=https://your-easy-panel-domain.com

# OIDC
ENABLE_OIDC_LOGIN=false
BASE_URL=
GRANT_ALL_INSTANCES_FOR_OIDC_USER=true
OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { popup } from "@/components/popup";
import { Icons } from "@/components/icons";
import { Textarea } from "@/components/ui/textarea";
import { copyToClipBoard } from "@/lib/clipboard";
import { env } from "@/env";

const ServiceInstanceSchema = z.object({
url: z.string().url(),
Expand All @@ -34,8 +35,9 @@ interface InstanceConfigDetailsProps {
}

function ChatGPTShareInstanceConfigDetailsPopup({ className, instanceDetails, closePopup }: InstanceConfigDetailsProps) {
const { url, id } = instanceDetails;
const configValue = `AUDIT_LIMIT_URL: ${url}/api/external/cockroachai/audit/${id}\n\nOAUTH_URL: ${url}/api/external/cockroachai/oauth/${id}`;
const { id } = instanceDetails;
const base_url = env.BASE_URL;
const configValue = `AUDIT_LIMIT_URL: ${base_url}/api/external/cockroachai/audit/${id}\n\nOAUTH_URL: ${base_url}/api/external/cockroachai/oauth/${id}`;

return (
<div className={cn("grid items-start gap-4", className)}>
Expand Down
3 changes: 1 addition & 2 deletions src/app/api/oidc/callback/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { writeUserLoginEventLog } from "@/server/actions/write-event-log";
import { eq } from "drizzle-orm";
import { users } from "@/server/db/schema";
import { UserCreateSchema, UserRoles } from "@/schema/user.schema";
import { redirect } from "next/navigation";

const OIDCUserInfoSchema = z.object({
sub: z.string(),
Expand Down Expand Up @@ -95,7 +94,7 @@ export async function GET(request: NextRequest) {
const sessionCookie = lucia.createSessionCookie(session.id);
cookies().set(sessionCookie);

redirect("/");
return NextResponse.redirect(new URL(env.BASE_URL));
} catch (error) {
console.error("Error in OIDC callback:", error);
if (error instanceof OAuth2RequestError) {
Expand Down
2 changes: 1 addition & 1 deletion src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const env = createEnv({

// SECRET_KEY: z.string().length(64), // run: openssl rand -hex 32

BASE_URL: z.string().optional().default("http://localhost:3000"),
BASE_URL: z.string(),
ENABLE_OIDC_LOGIN: booleanEnv.default(false),

GRANT_ALL_INSTANCES_FOR_OIDC_USER: booleanEnv.default(true),
Expand Down

0 comments on commit 5fdef6c

Please sign in to comment.