wonderful-photographer-65845
03/12/2025, 11:30 PMwonderful-photographer-65845
03/13/2025, 9:10 AMwonderful-photographer-65845
03/17/2025, 7:22 AMwonderful-photographer-65845
03/17/2025, 1:38 PMfaint-action-73893
03/17/2025, 4:47 PMfaint-action-73893
03/17/2025, 4:53 PMagreeable-receptionist-70632
03/21/2025, 10:07 AM{
"method": "password",
"csrf_token": "hSGQXu8ewpBie4kKU0UPYYP84PaB6rJ5tcYtgIF1o+QztLIoigO+W+n2ZWYeXqMshyvulaZkyS6A/wiWbzYO9g==",
"transient_payload": {
"last_name": "Maxime",
"first_name": "Test",
"birthdate": "2025-03-19T23:00:00.000Z",
"country": "fr",
"is_invitation_flow": true
},
"password": "epicBear99.",
}
Looking at the documentation, this payload is correct. Also, we have already a transient_payload with the Registration flow which is correctly transmitted to an after hook.
But unfortunately, with the after hook of the Settings flow, the transient_payload is not transmitted through the hook.
Here is the part of my settings kratos configuration :
...
selfservice:
flows:
settings:
ui_url: SOMETHING-TO-OVERRIDE
privileged_session_max_age: 336h
required_aal: highest_available
after:
hooks:
- hook: web_hook
config:
url: SOMETHING-TO-OVERRIDE
method: POST
body: <base64://ZnVuY3Rpb24oY3R4KSB7IGN0eDogY3R4IH0>=
auth:
type: api_key
config:
name: X-API-Key
value: API_KEY_HOOK
in: header
default_browser_return_url: SOMETHING-TO-OVERRIDE
methods:
password:
enabled: true
lookup_secret:
enabled: true
code:
enabled: true
link:
enabled: true
serve:
admin:
base_url: SOMETHING-TO-OVERRIDE
host: "0.0.0.0"
public:
base_url: SOMETHING-TO-OVERRIDE
cors:
enabled: true
allowed_origins:
- SOMETHING-TO-OVERRIDE
allowed_headers:
- Authorization
- Cookie
- Content-Type
exposed_headers:
- Content-Type
- Set-Cookie
allowed_methods:
- POST
- GET
- PUT
- PATCH
- DELETE
session:
lifespan: 336h
For information I use JS sdk 1.8.5 and kratos 1.3.1
Am I doing something wrong with my configuration ? Do we have something to understand really what is going on in Kratos ?jolly-ocean-26344
04/02/2025, 1:28 AM@ory/elements-react
does, and the @ory/integrations/next
method doesn't actually work for middleware with the .ory
route to get session data because you can't call relative urls from middleware
• https://github.com/ory/elements/blob/main/examples/nextjs-app-router/app/page.tsx
• https://www.ory.sh/docs/getting-started/integrate-auth/nextjsjolly-ocean-26344
04/10/2025, 6:53 PMbillowy-airplane-97030
04/12/2025, 1:57 PMmagnificent-football-29830
04/21/2025, 6:20 PMsalmon-optician-47309
04/28/2025, 5:11 AMgorgeous-rocket-30159
04/28/2025, 3:46 PMArray ( [error] => Array ( [id] => security_csrf_violation [code] => 403 [status] => Forbidden [request] => 05af83ac-4c27-953f-8eef-8ccc4ff405d0 [reason] => Please retry the flow and optionally clear your cookies. The request was rejected to protect you from Cross-Site-Request-Forgery (CSRF) which could cause account takeover, leaking personal information, and other serious security issues. [details] => Array ( [docs] => <https://www.ory.sh/kratos/docs/debug/csrf> [hint] => The anti-CSRF cookie was found but the CSRF token was not included in the HTTP request body (csrf_token) nor in the HTTP Header (X-CSRF-Token). [reject_reason] => The HTTP Cookie Header was set and a CSRF token was sent but they do not match. We recommend deleting all cookies for this domain and retrying the flow. ) [message] => the request was rejected to protect you from Cross-Site-Request-Forgery ) )
gorgeous-rocket-30159
04/28/2025, 5:03 PMgorgeous-rocket-30159
05/02/2025, 2:21 PMgorgeous-rocket-30159
05/02/2025, 2:34 PMgorgeous-rocket-30159
05/06/2025, 8:35 AMjolly-ocean-26344
05/07/2025, 2:52 AM@ory/client-fetch
code -- are there any examples?
At the moment, we have the below code snippet; the updateLoginFlow
call's network request returns a 422
with a redirect_browser_to
parameter, but for some reason that isn't returned in the actual ory client-fetch
call so I can't pass it back to the client to perform the redirect. Note that I'm logging things in the handleOryCall
script (which is necessary because sometimes these calls throw errors when they actually just succeed with a 400 or similar).
Any ideas? Is there a different suggested approach?
const { data: flow } = await handleOryCall<LoginFlow>(
async () =>
await ory.createBrowserLoginFlow({
returnTo: '/login',
}),
'initialize Google login flow',
);
logger.info('flow');
logger.info(JSON.stringify(flow, undefined, 2));
const csrfTokenNode = flow?.ui?.nodes.find(
(node: UiNode) =>
node.attributes.node_type === 'input' &&
(node.attributes as UiNodeInputAttributes).name === 'csrf_token',
);
const csrfToken = csrfTokenNode?.attributes
? ((csrfTokenNode.attributes as UiNodeInputAttributes).value as string)
: undefined;
if (!csrfToken) {
throw new Error('CSRF token not found in flow');
}
const providerNode = flow?.ui?.nodes.find(
(node: UiNode) =>
node.attributes.node_type === 'input' &&
(node.attributes as UiNodeInputAttributes).name === 'provider',
);
const providerId = providerNode?.attributes
? ((providerNode.attributes as UiNodeInputAttributes).value as string)
: '';
const response = await handleOryCall<SuccessfulNativeLogin>(
() =>
ory.updateLoginFlow({
flow: flow?.id ?? '',
updateLoginFlowBody: {
method: 'oidc', // OpenID Connect method
provider: providerId,
csrf_token: csrfToken,
},
}),
'update login flow to get Google auth',
);
billowy-airplane-97030
05/08/2025, 1:29 PMserve.opl
block.
I'm not entirely sure what the serve.opl.write_listen_file
is supposed to do. I suspect that this might have something to do with the /opl/syntax/check
HTTP endpoint, but the description of that endpoint is pretty vague.
Very quickly can someone give me a quick rundown of what this config option is and what it does please :3?billowy-airplane-97030
06/02/2025, 9:15 AMwebfinger
config block in Hydra implements the WebFinger protocol (RFC 7033) or its just a wrapper for OIDC discovery and JWKS?billowy-airplane-97030
06/02/2025, 9:20 AMelegant-potato-3021
06/26/2025, 9:24 AM/
with my vercel domain I got:
GET <https://eager-franklin-3vbqv90l3p.projects.oryapis.com/sessions/whoami> 401 (Unauthorized)
so, request to whoIam returns 401 and after that I was redirected to welcome page <https://eager-franklin-3vbqv90l3p.projects.oryapis.com/ui/welcome>
where my session is presented (because I logged in previously).
For some reason, on my vercel domain, it can't find the cookie session and redirect to the welcome page (in ory console it's a default path as far as I remember).
Previously I had an issue with CORS and I fixed it with this: https://www.ory.sh/docs/guides/cors#enable-cors
I think, the issue is a configuration in ory console, But I couldn't figure it out 😓
If I logged out from welcome page and go again to vercel domain, I will be redirected to <https://eager-franklin-3vbqv90l3p.projects.oryapis.com/ui/login?flow=2175c2df-d424-4497-aba1-bbed122aa473>
after successful signing in, i saw for a moment my vercel domain home page with null sessions and was redirected again to welcome page, because whoami retured 401
any ideas? 🙂
The code is the same as in quickstart:
useEffect(() => {
// Check if the user is authenticated
const checkSession = async () => {
try {
// Browser automatically includes cookies in the request
const session = await ory.toSession()
setSession(session)
// Get the logout URL once we have a session
try {
const { logout_url } = await ory.createBrowserLogoutFlow()
setLogoutUrl(logout_url)
} catch (logoutError) {
console.error("Error creating logout flow:", logoutError)
}
} catch (error) {
console.error("Error ory.toSession()", error)
// No valid session found, redirect to Ory login
window.location.href = `${basePath}/ui/login`
}
}
checkSession()
}, [])
rapid-caravan-83620
07/11/2025, 1:21 PMalert-oyster-16871
07/12/2025, 3:30 AMory tunnel --project <site-id> <http://localhost:5173>
but am experiencing some interesting behaviour. Firstly the redirect consistently takes me to /ui/welcome
rather than back to localhost:5173
. I have tried numerous methods for resolving this but nothing consistently works. When I run the ory tunnel and change the base url to <http://localhost:4000>
it fails to authenticate and send a session token. My page constantly refreshes looking to make a connection.
Secondly, I recieve the following error Property 'logout_url' does not exist on type 'AxiosResponse<LogoutFlow, any>'.
on const { logout_url } = await ory.createBrowserLogoutFlow();
. To get the type correctly I need to use
const logoutFlow = await ory.createBrowserLogoutFlow();
setLogoutUrl(logoutFlow.data.logout_url);
You may want to update your documentation to reflect this.
Hoping someone can provide some advice around the best way to resolve my issues. Thanks
I have attached below some relevant code snippets
import { createContext, useContext, useEffect, useState, type JSX } from "react";
import { Configuration, FrontendApi, type Session } from "@ory/client";
interface AuthContextType {
session: Session | null;
logoutUrl: string | null;
loading: boolean;
error: string | null;
}
const basePath: string = (import.meta.env.VITE_ORY_SDK_URL);
export const ory = new FrontendApi(
new Configuration({
basePath,
baseOptions: {
withCredentials: true,
},
}),
);
const AuthContext = createContext<AuthContextType>({
session: null,
logoutUrl: null,
loading: true,
error: null,
});
export const useAuth = (): AuthContextType => useContext(AuthContext);
export const AuthProvider = ({ children }: { children: React.ReactNode }): JSX.Element => {
const [session, setSession] = useState<Session | null>(null);
const [logoutUrl, setLogoutUrl] = useState<string | null>(null);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const fetchSession = async (): Promise<void> => {
try {
setLoading(true);
setError(null);
const { data: sessionData } = await ory.toSession();
console.log("Session data:", sessionData);
setSession(sessionData);
try {
const logoutFlow = await ory.createBrowserLogoutFlow();
setLogoutUrl(logoutFlow.data.logout_url);
} catch (logoutError) {
console.error("Error creating logout flow:", logoutError);
}
} catch (err) {
console.error("Error fetching session:", err);
window.location.href = basePath + "/self-service/login/browser";
} finally {
setLoading(false);
}
};
useEffect(() => {
fetchSession();
}, []);
if (loading) {
return (
<div className="flex items-center justify-center min-h-screen">
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
</div>
);
}
if (error) {
return (
<div className="flex items-center justify-center min-h-screen">
<div className="text-center">
<div className="text-red-600 text-xl mb-4">Authentication Error</div>
<div className="text-gray-600 mb-4">{error}</div>
<button
onClick={() => window.location.reload()}
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
>
Retry
</button>
</div>
</div>
);
}
return (
<AuthContext.Provider value={{ session, logoutUrl, loading, error }}>
{children}
</AuthContext.Provider>
);
};
export const ProtectedRoute = ({ children }: { children: React.ReactNode }): JSX.Element => {
const { session, loading } = useAuth();
if (loading) {
return (
<div className="flex items-center justify-center min-h-screen">
<div className="animate-spin rounded-full h-32 w-32 border-b-2 border-gray-900"></div>
</div>
);
}
if (!session) {
return (
<div className="flex items-center justify-center min-h-screen">
<div className="text-center">
<div className="text-xl mb-4">Please log in to access this page</div>
<button
onClick={() => {
window.location.href = basePath + "/self-service/login/browser";
}}
className="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
>
Go to Login
</button>
</div>
</div>
);
}
return <>{children}</>;
};
And the following is how I am attempting to access the logout_url
for the location of my log out button
const { logoutUrl } = useAuth();
const handleLogout = (): void => {
ory
.createBrowserLogoutFlow()
.then(({ data }) => {
if (logoutUrl) {
window.location.href = data.logout_url;
} else {
console.error("Logout URL not available");
}
});
};
alert-oyster-16871
07/12/2025, 4:17 AM.github/workflows
to configure these environments with a code first approach rather than configuring them in the ory dashboard.wide-magician-53997
07/13/2025, 6:32 PMInput
, Button
, etc.) based on a custom design system.
Now I’m planning to integrate Ory for authentication (login). I saw that there’s Ory Elements, and I’m wondering:
👉 Should I use Ory Elements and override its components with my own from the design system?
Or
👉 Is there a better/recommended way to customize the UI while still using Ory?
Thanks in advance for any guidance! 🙏high-lawyer-6571
07/17/2025, 7:03 PMhigh-lawyer-6571
07/17/2025, 7:05 PMory tunnel --project <slug-id> <http://localhost:3000>
returns below error :
Error: No project found with slug or ID <slug-id>high-lawyer-6571
07/17/2025, 7:05 PMory use project <project-id>
shows correct projcthigh-lawyer-6571
07/17/2025, 7:07 PM