Skip to content

Commit

Permalink
fixed envs
Browse files Browse the repository at this point in the history
  • Loading branch information
mirai2k committed Nov 22, 2024
1 parent fed7ece commit fc668c8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
3 changes: 3 additions & 0 deletions apps/auth-service/src/schemata/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ export const environmentSchema = object({
CLERK_JWT_KEY: string(),
APP_TOKEN_TEMPLATE: string(),
ZITADEL_URL: string(),
AUTH_OPENID_ISSUER: string(),
CLIENT_ID: string(),
REDIRECT_URL: string(),
VERIFIED_PUBLISHERS: pipe(
unknown(),
transform((input) => {
Expand Down
14 changes: 5 additions & 9 deletions apps/auth-service/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ import { createLoginIntent } from "./handlers/intents/create.js";
import { getLoginIntent } from "./handlers/intents/get.js";
import { populateLoginIntent } from "./handlers/intents/populate.js";

const AUTH_OPENID_ISSUER =
process.env.AUTH_OPENID_ISSUER ?? "http://codemod-zitadel:52000";
const CLIENT_ID = process.env.CLIENT_ID ?? "291351851578753026";

type ZitadelUserInfo = {
sub: string;
name: string;
Expand Down Expand Up @@ -127,11 +123,11 @@ export const initApp = async (toRegister: FastifyPluginCallback[]) => {
return fastify;
};

const issuer = await Issuer.discover(AUTH_OPENID_ISSUER);
const issuer = await Issuer.discover(environment.AUTH_OPENID_ISSUER);

const client = new issuer.Client({
client_id: CLIENT_ID,
redirect_uris: ["http://localhost:8080/callback"],
client_id: environment.CLIENT_ID,
redirect_uris: [environment.REDIRECT_URL],
response_types: ["code"],
token_endpoint_auth_method: "none",
});
Expand Down Expand Up @@ -171,7 +167,7 @@ const routes: FastifyPluginCallback = (instance, _opts, done) => {
).toString();

const { access_token } = await client.callback(
"http://localhost:8080/callback",
environment.REDIRECT_URL,
params,
{
code_verifier: codeVerifier,
Expand Down Expand Up @@ -332,7 +328,7 @@ const routes: FastifyPluginCallback = (instance, _opts, done) => {

try {
const { data: user } = await axios.get<ZitadelUserInfo>(
`${process.env.ZITADEL_URL}/oidc/v1/userinfo`,
`${environment.ZITADEL_URL}/oidc/v1/userinfo`,
{
headers: { Authorization: `Bearer ${jwtToken}` },
timeout: 5000,
Expand Down

0 comments on commit fc668c8

Please sign in to comment.