Require initial setup before running spring web app - spring-mvc

I'm creating a very simple forums application.
My current problem is i want the user to be prompted with a setup page (what they'll use to set initial settings such as MySQL credentials) if the website has yet to be setup. When they attempt to go to website.com/login, it should redirect them to website.com/setup until the setup is fully finished.
Should i just use an interceptor for this, or is there an alternative? Also, if i use an interceptor, is it possible to "unregister" it when the website has been fully setup?

Related

ASP.Net redirecting to local host after authentication

I just created a webform that is hosted in my Azure subscription. I set it up with authenication via my works Azure directory for authenticating users. In debug this works fine and I am able to login with my work credentials and then view the website via local host.
I have published this to my Azure and it says it is running and working fine. So when I try to connect to the website it continuously redirects me to the localhost resulting in an error.
I have checked the web config.
Here is the google network chain of events when it occurs.
I am really lost as to what is wrong and what I need to do to fix this so any help would be greatly appreciated. I'm sorry I can't offer more but I don't even know what is wrong to begin with or where to look. Is there some setting in Azure that I need to add the website too?
I have solved this issue. Since it was such a pain I will keep this up as I couldn't find any answers on this. It was actually quite simple.
You have two options. The one I did and which worked was changing the publish profile as below:
Add the domain where the authentication is occurring. So if you have your web app hosted by a different azure account that which is authenticating the users, use the one that is authenticating.
This will create two versions of your app on the site one for local host and one for the actual site.
The second option(I have not tried this but it should work) is to go to the Azure account where you are authenticating the users and go to applications and then configure. Change the APP URL from local host to the url you are trying to get to.
Here is an excellent link that explains how to do this clearly.
Click this link for detailed explanation
I also had this issue and took these steps to resolve
navigate to the app registration in AAD
Open the manifest
Change the ReplyUrl to the url of the app (e.g. http://appname.azurewebsites.net)
Then I got the error
Bad Request - Request Too Long HTTP Error 400. The size of the request headers is too long.
Next I cleared all cookies from the browser, and this changed the error to just
Bad Request
So I went back to that ReplyUrl and changed it to https://appname.azurewebsites.net/.auth/login/aad/callback and now it appears to work.
Note I also had to make sure I didn't have the site open in any other tabs before it started working
I had this issue when I switched an app from our company Azure over to a customer's Azure. In my case I'd forgotten to update the ida:ClientId, ida:AADInstance and ida:TenantId, which then meant that the value I'd set for ida:PostLogoutRedirectUri was ignored (I think) and instead my app redirected to localhost.
Once I changed those ida values to the values from the app settings and subscriptions settings on our customer's Azure it all worked as expected.
It took a while to track down all the values in Azure portal as they are all called something different, or aren't named at all:
ClientId can be found at Azure Active Directory > App Registrations > YourAppName. It's called 'Application ID' in Azure
Domain can be found on Azure Active Directory > Overview. It's currently in the top left in the format somename.onmicrosoft.com
TenantId this is the Azure AD instance ID, get that from Azure Active Directory > Properties and then it's called 'Directory ID'
I spent a lot of time trying to work out where the localhost port that was being redirected to was in the code, but it simply isn't there as far as I can see, so I have no idea how Azure was choosing what localhost address to redirect to!
You need to set another parameter in configuration that is replyUrl and assign to your web app, other wise it takes the url from which it was originated.
I was able to fix this by changing my Startup.Auth.cs file redirectUri from "https://localhost:44316/" to https://myapp.com/

Adding authentication module to an existing servlet 3 app without modifying it

I need to add an authentication layer to an existing Servlet 3 web application which is deployed with a *.war file without modifying it (because I do not own it).
I have a vague idea of how this can be achieved, however I am not sure of the details of how this can be done and if this is possible at all.
The vague idea I have is to add another web module to the application and make it intercept all requests and check if there is an active session. If there is, then I allow the request to be handled by the original web module, if not then I make user authenticate, create session and redirect user to the original url. By the way, the container I am using is IBM WebSphere so having *.ear files is ok.
I have no idea where to start from. I imagine that I can implement a servlet filter on the authentication module, but how can I make the original application also use this filter?

In Symfony is there a way to access the app_dev information with REST

I am trying to optimize my app and have been using the profiler you get with app_dev to be very useful, especially the doctrine panel.
Is there any way to log this information to a file so I can see what is happening when I POST / PUT to a RESTful controller?
When you using development enviorment (app_dev.php) profiler works independend of the fact of displaying toolbar unless you force to disable it via config.
You can view all the profile data after successfull or failed request via http://your.app.address/_profiler/
If it is not enough there is a way to
Change profile storage engine
Access profile during local tests

Unable to login to PiranhaCMS after setup

I've installed PiranhaCMS on an existing ASP.NET MVC5 application. Part from I had to install AutoMapper, the installation went through smouthly. I followed the Get Started instruction in the "Adding Piranha CMS to an existing application". I've tried using existing database, the incluede CE database, and event with a new database. It all comes down to the same problem, I get routed to "/manager/install" where I set up the admin user (which gets added to the sysuser table). After this I get routed to the "/manager" page where I get to sign in with the user i just created. When logging in, I get back to the same page. I assume, the user is not valid... but I get no exception or other information.
Any ideas?
try to remove this node in your web.config
system.webServer/modules
What worked for me was removing the system.webServer/modules like mentioned above and also changing
system.web/authentication mode="None"
to /authentication mode="Forms"
The authentication mechanism for the manager uses Forms authentication. Since you just get routed back to the login I'm guessing Forms auth isn't enabled so the cookie doesn't get set!
Removing system.webServer/modules will disable the way MVC application (such as in defulat template) manages loging in users. Having authentication mode to "Forms" is part of getting started tutorial.
It is quite possible (and is in my case) that replacting authentication is not desired behaviour.
The question is how to let those two authentification mechanisms live side by side. I know that we'll have to keep users separated. That is fine. But how to run run two authentications side by side?

External website in .NET and Active Directory

I'm building a website and I need authenticate a User using Active Directory.
My website is on a different network and IP from the Server where the Active Directory is running (it is in a completely different network and domain).
I would like to know if is possible build an Login Page which could authenticate an User on a remote AD.
Thanks for your time.
One way of doing it would be to use LDAP to validate the supplied user credentials. Here is an example from Microsoft on how you could do it.
You should not deploy any web services on an Active Directory server.
You can use System.Directoryservices.Accountmanagement namespace classes (.NET 4) or using ADSI.
I had a similar situation to this, and the only way I could think to do it was like this:
Create a very small website on the server with Active Directory, which uses windows authentication
Have this website redirect to your main website, with some form of login key in the URL (best if generated on the fly) if the user authenticated.
Don't think there is any way for you to use the authentication over the external website other than along these lines.

Resources