-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
question: inject headers not presented #325
Comments
@MrOzean , first, use container from https://github.com/authcrunch/authcrunch/pkgs/container/authcrunch Next, add enable debug and add trace. See here https://github.com/authcrunch/authcrunch.github.io/blob/8df7a112fbf2f8c34e5a69a1be33bbeb42d4af62/assets/solutions/A00001/Caddyfile#L96 Post the request trace here. It should contain X headers. Additionally, watch the video related to X-Headers: https://youtu.be/mDRFLX14zTk?si=uC3OZDVJ1quwSzUG Your goal is to get X headers propagated to your proxied application. As for the automated redirect, it is done with JS. I will add a video in how to do it. |
@MrOzean , the javascript directive that can include JS code that redirects users to their own dashboards can be found here: |
@MrOzean , review the section again: https://docs.authcrunch.com/docs/authenticate/ui-features#javascript I added I will soon publish a video about this use case www.youtube.com/@AuthCrunch |
Hello, thanks for fast reply |
At current version added trace to route
Navigate to dash.example.com -> push login button -> push whoami button
|
@MrOzean , where is the log when tou try going to a dashboard? |
Also, something strange. There are no traces in the log. remove rewrite directive and the has conditional. |
@MrOzean , please reach out on whatsup (12123807343), I will try to explain over the phone. |
First I think need to update container. As I say, link https://github.com/authcrunch/authcrunch/pkgs/container/authcrunch follow 404 error, tried to use ghcr.io/authcrunch/authcrunch:v1.0.7 got authorization error |
About phone call, not good idea. My English speaking far from perfect + 12 hours time difference + this conversation can help anyone else |
JS redirect works perfectly, thanks. Working solution caddyfile
js file (async () => {
console.log("Injected JS Found");
const whoamiEndpoint = "/whoami";
const portalEndpoint = "/portal";
const dashboardBaseUrl = "https://dash.example.com";
async function fetchUserData(path) {
try {
const response = await fetch(path, {
method: "GET",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
},
});
if (response.ok) {
const data = await response.json();
return data;
} else {
console.log(path, 'fetch returns not success status', response.statusText)
}
} catch (error) {
console.log("encountered error while fetching user data", error);
}
return null;
}
try {
if (typeof window !== "undefined") {
const currentURL = new URL(window.location.href);
if (currentURL.href === dashboardBaseUrl + portalEndpoint) {
console.log(currentURL);
const userData = await fetchUserData(dashboardBaseUrl + whoamiEndpoint);
if (userData && "email" in userData) {
const email = userData['email'];
const userId = email.substring(0, email.indexOf('@'))
console.log(
`Redirecting user ${userId} to ${dashboardBaseUrl}/${userId}`
);
const redirectUrl = 'https://' + userId + '.' + (new URL(dashboardBaseUrl)).hostname;
window.location.href = redirectUrl;
} else {
console.log("No email found in user data", userData);
}
}
}
} catch (error) {
console.log("encountered error", error);
}
})(); |
I can speak Russian. |
@MrOzean , glad this is resolved! |
Thanks for help! |
I recorded a video about this one: https://youtu.be/DAzfxtqxD5s |
Hello, I have a bunch of dashboard and want to make auto redirect based on user email
My setup is
Authentik 2024.2.2 as "Generic OIDC provider" at "sso.example.com"
Caddy in docker from ghcr.io/authp/authp:v1.0.5
Auth portal at "dash.example.com"
Users dashboards at "USER_NICKNAME.dash.example.com" baked by reverse_proxy directive
My caddyfile
Login works correctly, but no one headers from JWT was provided
caddy log
/whoami ouput
Chrome devtools also has not show extra headers
The text was updated successfully, but these errors were encountered: