Get root url in Keycloak login theme - keycloak

Is it possible to get the root url in the Freemaker's template used by Keycloak login theme? The closest one I found is inside the client bean:
keycloak-master\services\src\main\java\org\keycloak\forms\login\freemarker\model\ClientBean.java
public String getBaseUrl() {
return ResolveRelative.resolveRelativeUri(session, client.getRootUrl(), client.getBaseUrl());
}
Which can be called in a Freemaker tamplete:
${client.baseUrl}
However, the client.getRootUrl() itself is not exposed. Is it possible to get root url without changing the service source code, just using the Freemaker template in the Keycloak theme?

If it's just for displaying it in the page, use Javascript and it'll be evaluated at client side:
<label id="yourLabel">test</label>
<script>
var root = window.location.origin;
document.getElementById('yourLabel').innerHTML = root;
</script>
See also:
Change label text using JavaScript
How to extract the hostname portion of a URL in JavaScript

Related

Spring Security logout success url to another host

is that possible to make Spring Security 3.2.7.RELEASE redirect user to another host after logout? I can't force it to use another host. I'm using some kind of SSO access system and that might be a problem.
Example:
My app is started on http://myAppUrl:8080/webapp1/
Users access it through http://ssoAccess:80/webapp1/ and that leads to real url, but in browser i still see ssoAccess url all the time (like some kind of proxy)
I want to make logout button from http://myAppUrl:8080/webapp1/logout.xhtml
to logout then redirect to http://ssoAccess:80/appList
When logout-success-url is set to "http://ssoAccess:80/appList" it redirects to http://ssoAccess:80/webapp1/http://ssoAccess:80/appList which is obviously not correct url returning 404.
I tried logout-success-handler as well, but still same problem. I also tried to make #Controller that has method returning "redirect:http://ssoAccess:80/appList" on endpoint that is pointed by logout-success-url. Still no luck.
I'm also using JSF.
Please help!
A simple trick is that you create a logout.xhtml page in webapp1 that redirect's to appList.
logout.xhtml:
<script language="javascript">
window.location.href = "http://ssoAccess:80/appList"
</script>

SharePoint Online: Redirect URIs for multi-site environment

We have a multi-site environment where each site has its own redirect URL. We want to use a single Client ID and Secret for our application but register multiple redirect URIs to it. Is it possible to add multiple URLs in below registration form:
I don't think there is possible solution to add on multiple URLs on the SharePoint online app registration form.
But from what i understand there is another way to achieve use a single Client ID and Secret for application and perform multiple redirects.
You can control the redirect url using the appredirect.aspx by specifying the redirect_uri parameter if you need to redirect from the default one check here for reference.
Basiclly it call the subsite page containing the below JS to install the app.
var url = String.format(
"{0}/_layouts/15/appredirect.aspx?client_id={1}&redirect_uri=https://***.azurewebsites.net/<<controller>>/<<view method containing the code to install the app>>?{{StandardTokens}}",
<<subsite url>>, "<<client id>>");
window.location.href = url;
The above javascript calls the appredirect.aspx page which then calls the app site as below,
https://****.azurewebsites.net/home?SPHostUrl=<<subsiteurl>>&SPLanguage=en-US&SPClientTag=1&SPProductNumber=**&SPAppWebUrl=<<weburl>>
Note: The above can be extended to check for the successful installation of the app and display an error message accordingly.
SPWeb.LoadAndInstallWeb equivalent REST / Javascript CSOM is also available here.
Here are some relevant links:
Use the redirect URL in an add-in that asks for permissions on the fly
Redirect URIs and a sample redirect page

How to set logout redirect in felogin plugin in TYPO3 6.2?

I'm using felogin - to get it to work I set it up in TypoScript in my root template:
plugin.tx_felogin_pi1 {
storagePid = 40,38,36,35,51
showForgotPasswordLink = 1
redirectMode = groupLogin,userLogin,login,loginError
redirectPageLogout = 6
...
It works fine, except when I try to logout while being on a page with restricted access because then it tries to find that restricted-page and for those cases I set up the install tool to redirect it to a "Page not found" template.
I noticed the logout-form action always points to the page ID I'm currently on:
<form action="index.php?id=49" target="_top" method="post">
so that's not what I want...I would like it to always be action="index.php?id=6" but my redirectPageLogout = 6 line didn't manage to change it.
Anyone an idea how can I change this?
In the felogin html template there's just ###ACTION_URI### and idk where it gets that from in the logout-form but I wanna play by the rules and not change it in the template directly...unless there's no other way.
You need to have access to a login-/logout-plugin after your logout is processed to get the forwarding working.
So if your logout plugin is on a page which is only invisible for logged in user. the logout is processed, but your redirect can't be processed (the default-handling of TYPO3 takes over and throws you to a page which is accessable). The same occurs if only the plugin itself is only visible for logged in users.
if you target the logout form directly to a page with a plugin visible for all, first the logout and secondly the redirect can be processed always.

Response redirect using IP in dotnetnuke

I am hosting and developer on my DNN portal. I need to redirect users using client IP. I think may be two ideas for this work.
1- DNN Setting
Maybe DNN has settings for it that I can set specific URL for client IP addresses and automatically DNN redirects to specific URL.
I read many topic but I could not find setting to do it.
Is there a way to do this?
2- New Module
I have a ascx that onload method has this code:
var IP = Server.HtmlEncode(Request.UserHostAddress).ToString();
using (Entities db = new Entities())
{
var retVal = db.URLAddresses.Where(u => u.IPAdress == IP).FirstOrDefault();
if (retVal != null)
Response.Redirect(retVal.URL);
}
But I should add this code to any ascx for redirect using client IP. This is impossible because maybe I haven't source code modules.
I think I should create new module. So I can add it to page. Module changes onload page and redirect to URL using client IP.
In this scenario, I try to create new module but I don't know how I can change onload method each page that is added module to it?
You can use IHttpModule and make a new Module for Including your class then you should add your IHttpModule to web.config .
For e.g
<add name="YourModule" type="YourAssembly, YourNameSpace" preCondition="managedHandler" />
See this Sites:
HTTP Handlers and HTTP Modules Overview
and How To Create an ASP.NET HTTP Module
DNN does have a Host setting that will allow or deny access to users logging in based on their IP address. It's in Host Settings > Advanced Settings > Login IP Filters. I don't think that will give you the desired result.
I would not suggest creating a module. It can be difficult copying it to all pages and ensuring one instance is added to every page.
Rather, I would create a skin (theme) token. To do this, create a simple class library project. Create an .ascx and ascx.cs file. You can leave the .ascx empty because you don't have any html to add to the pages. In the .cs, put something like this:
namespace MyCompany.DNN.Skin
{
public partial class IpRedirect : SkinObjectBase
{
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
// Put your redirect logic here
}
}
}
Then, in your theme/skin ascx pages, include the following:
<%# Register TagPrefix="myco" TagName="IPREDIRECT" Src="~/DesktopModules/MyCompany/IpRedirect/IpRedirect.ascx" %>
<myco:IPREDIRECT ID="pageRedirect" runat="server" />
This will ensure that this functionality will execute on all pages in the site that use the skin/theme.

Redirect to default action in symfony

I'm using Symfony 1.4 to build a web application. The home page action for this application is as follows.
Module = content
Action = indexAction.php
/localhost/myapp/web/index.php/content/
I need to use this action as the defalut action when someone access the application folder using web browser. If someone access the myapp folder as follows.
/localhost/myapp
It should internally redirect to the
/localhost/myapp/web/index.php/content/
and access the homepage.
I guess Symfony routing will not work here. Can someone help me on this.
Using the symfony routing system, you can define the default module / action for the /.
In the myapp/config/routing.yml, define the homepage route (it's defined by default):
# default rules
homepage:
url: /
param: { module: content, action: index }
This way, accessing /myapp won't redirect you but you will be on your homepage.