How does Spring work with apparently no code? - spring-mvc

I am trying to understand the example described here.
What is puzzling to me is that there is apparently no code. I run the spring-security-samples-insecuremvc-3.2.x within Tomcat and a form is presented to interact with but there is no Java code whatsoever as far as I can see. I can't even find the form. I realize that the code must be in one of the dependencies but I am baffled at how this all works.

Spring does generate/provide a default login form if it's configured to do form-based login and no custom login form is configured.
Sidenote: how to create and configure a custom login form is, for example, explained here: http://docs.spring.io/spring-security/site/docs/3.2.x/guides/form.html (to long to be copy/pasted here).

I have been looking at this sample today with the same questions as you - where the heck is the source? I finally found the answer I think you're looking for. Take a look at the pom.xml and in the dependencies you'll see spring-security-samples-messages-jc. Assuming you downloaded all the samples, import that project into STS and you'll find the files you're looking for.
BTW, I've been following the instructions on the spring security website to add security to this sample and I have not yet been able to get it to work - the login screen does not appear. Let me know if you have better luck than me.

The default spring security login form is generated by the class org.springframework.security.web.ui.DefaultLoginPageGeneratingFilter which is in spring-security-web-$version.jar
The method is generateLoginPageHtml()

Related

API setup missing something?

I am setting up a web api for the first time and I have another project for reference. It is a .NET framework project that will have a React frontend. I am running it using Visual Studio and IIS Express.
I have no build errors when I start the api project. It has swagger added so I can test database calls, so I know the api itself is working. But I am missing adding something as I am looking to add more security to it.
I am trying to verify authentication and I want to use integrated Windows authentication. When I set a break point, the user in the HttpContext.Current is never set and is never authenticated, so I can't add any authorization filters.
I went back to just the basic empty api project that has the frontend web pages removed to see if I removed something and it shows the same issue. So I either removed it again or I am actually missing adding something.
I am not sure where to look for what is missing, so any pointers would be appreciated.
The left browser is what I am expecting and the right browser is what I am seeing.
I don't need the directory browse turned on, so seeing a 403.14 - Forbidden is fine. But I am clearly missing something to get to that point. Is there a better way to figure out which resource/dependency is causing this error?
I can also see the working version requested url is what I am expecting, but the other is just a /.
Is there a way to resolve that if this is the error?
I can add code snippets if needed, but I haven't yet as I am not sure where the issue is.
I ended up finding the answer using blank test web apis to see what I may have left in that wasn't needed. The project was set up using this option:
After removing the views, etc., to make it strictly an api project. I started removing references (and clearing the associated errors) and seeing what happened with the build after each change.
Under the App_Start folder, there were some additional files that weren't present in the project I had for comparison - FilterConfig, and RouteConfig - which were also called in the Global.asax.
I removed the call in Global.asax for all three and I was able to see the expected http error page.
I dont have enough reputation for a comment, but you got 404 error, which, as you know, means there is nothing on that url. So check the route config and startup.cs Edit: I am on the phone so I didnt saw you already solved it. Good :)

Can't Send Email from Mobius form

I'm trying to create a simple form, but not getting very far.
I deleted all the extensions etc and then reinstalled so I just had the basic setup.
I select a Contact Form, and updated the owner email. Yet it gave me an error saying sender address not specified.
Any help would be appreciated.
Screenshot 1 at https://www.screencast.com/t/PgpsPn0P8mrb
Screenshot 2 at https://www.screencast.com/t/G9cKnRN2
I couldn't find any log entries for the sending. In the DNN logs there were lots of errors with HttpClient not found from MailChimps.cs, but I'm not wanting to use MailChimp. In my previous attempt I tried removing mailchimp references from the code and still got these errors.
I like the concept, but I find the help very unhelpful, often out of date and it assumes way to much. I'm willing to persist, but I'm under time contrainsts and it may be just easier to build my own module in C#.
You can set this globally, or on each form in the normal form configuration:

Epandframework security module configuration

I am using XAF from devexpress, I just added the security module from the expandframework and all my navigation disappears for non administrative users.
Am using XAF's new security system all well configured even navigation.Is there
extra configuration that am unaware of in expandframework?(am new to the expand framework)
The info you posted is not enough to determine this behavior. For each eXpandFramework module there is a set of tester solutions located # https://github.com/expand/eXpand/tree/17.2/Demos/Modules I suggest you look how the SecurityTester solution is configured and try to see what might differ. SO is not the best place to post such questions as there are dedicated forums and I happy to help you if you post a sample demonstrating this case there.

Accessing asp.net mvc routing table in an http module

Is it possible to access the routing table in an HttpModule.
But, in fact, more specifically is it possible to programatically figure out which route was taken?
Glimpse will also show you which route was selected, and it's source will also show you how to get access to the currently selected route.
Technically this is possible.
Check out Haack's Route Debugger code. It may help you gain insight into how to accomplish this for your specific needs.
http://haacked.com/archive/2008/03/13/url-routing-debugger.aspx
Not only can you get this bits to this, it is also a nuget package as well.
I think this will point you in the right direction to get started.

How to register a IHttpModule in Orchard which has access to the DefaultContentManager (or the equivalent)

I have been trying to write something for orchard which will check all requests for "_escaped_fragment_" signifying a google ajax crawling request and will perform a 301 redirect to the correct resource which needs to be looked up using the DefaultContentManager.
I had done something like this in a previous project by extending IHttpModule and registering it using
<httpModules>
<add name="GoogleRedirect" type="MyNameSpace.GoogleRedirect"/>
</httpModules>
but have found that using the same approach I can't get access to the orchard content manager.
ie. the following doesn't work
_contentManager = DependencyResolver.Current.GetService<IContentManager>();
I also noticed that Orchard uses Autofac and have been trying to get a line similar to ContainerBuilder().Build().Resolve<IContentManager>() working but the ContainerBuilder doesn't seem to be exposed anywhere?
Is there any way of accessing the DefaultContentManager without having to rewrite the code I currenty have? If not is there a special Orchard way of doing this? What is the easiest way to do it and are there any guides to doing anything similar / any bits of code I can examine? I have been reading through the documentation but not sure of the best way of doing it?
Will carry on reading anyway any help appreciated.
Update
After doing some searching I found the following post:
http://www.deepcode.co.uk/2011/05/real-world-orchard-cms-part-4-cleaning.html
Which has an example of using filters. Just in case anyone else has any problems, I found that my Themes folder was never hitting any of the break points. After comparing with another project I noticed that the theme I had created did not have its own project file. To sort this out I recreated my theme using
codegen theme MyTheme /BasedOn:TheThemeMachine /CreateProject:true /IncludeInSolution:true
No, I don't think this is possible. Any particular reason why you need to do this in a module rather than, say, a filter?

Resources