mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-07-01 20:49:18 +00:00
NORY-14: refactor Kratos and Hydra APIs (authentication)
This commit is contained in:
parent
215d47e888
commit
9ee7da3a6c
12 changed files with 51 additions and 27 deletions
|
@ -3,7 +3,7 @@
|
|||
import { AxiosError } from 'axios';
|
||||
import React, { DependencyList, useEffect, useState } from 'react';
|
||||
|
||||
import { kratos } from './sdk/kratos';
|
||||
import { kratos } from './sdk/client';
|
||||
import { AppRouterInstance } from 'next/dist/shared/lib/app-router-context.shared-runtime';
|
||||
|
||||
export const HandleError = (
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export * from './hooks';
|
||||
export * from './ui';
|
||||
export * from './sdk/kratos';
|
||||
export * from './sdk/client';
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
'use server';
|
||||
|
||||
import { Configuration, OAuth2Api } from '@ory/client';
|
||||
|
||||
// implemented as a function because of 'use server'
|
||||
export default async function getHydra() {
|
||||
return new OAuth2Api(new Configuration(
|
||||
new Configuration({
|
||||
basePath: process.env.ORY_HYDRA_ADMIN_URL,
|
||||
baseOptions: {
|
||||
withCredentials: true,
|
||||
},
|
||||
}),
|
||||
));
|
||||
}
|
39
authentication/src/ory/sdk/server/index.ts
Normal file
39
authentication/src/ory/sdk/server/index.ts
Normal file
|
@ -0,0 +1,39 @@
|
|||
'use server';
|
||||
|
||||
import { Configuration, FrontendApi, OAuth2Api } from '@ory/client';
|
||||
|
||||
|
||||
// ####################################################################################
|
||||
// OAuth2 API
|
||||
// ####################################################################################
|
||||
|
||||
const oAuth2Api = new OAuth2Api(new Configuration(
|
||||
{
|
||||
basePath: process.env.ORY_HYDRA_ADMIN_URL,
|
||||
baseOptions: {
|
||||
withCredentials: true,
|
||||
},
|
||||
},
|
||||
));
|
||||
|
||||
export async function getOAuth2Api() {
|
||||
return oAuth2Api;
|
||||
}
|
||||
|
||||
|
||||
// ####################################################################################
|
||||
// Frontend API
|
||||
// ####################################################################################
|
||||
|
||||
const frontendApi = new FrontendApi(
|
||||
new Configuration({
|
||||
basePath: process.env.NEXT_PUBLIC_ORY_KRATOS_URL,
|
||||
baseOptions: {
|
||||
withCredentials: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
export async function getFrontendApi() {
|
||||
return frontendApi;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue