Skip to main content


Showing posts from March, 2012

Simplest Authentication in Lift

Lift has been an interesting experience so far, particularly since I'm learning Scala at the same time. Lift comes with quite a few built-in mechanisms to handle various features, such as authentication, authorization and role-based access control. A lot of the documentation utilizes these built-ins to good effect, but because the core mechanisms are complete skipped, you have no idea where to start if you have to roll your own authentication. A suggestion for Lift documentation: cover the basic introduction first, then show how Lift builds on that foundation. I present here the simplest possible authentication scheme for Lift, inspired by this page on the liftweb wiki : object isLoggedIn extends SessionVar[Boolean](false) ... // in Boot.scala LiftRules.loggedInTest = Full(() => isLoggedIn.get) That last line only needs to return a boolean. If you wish to include this with Lift's white-listed menu system, you merely need to add this sort of test: val auth = If(() =&g

Debugging Lift 2.4 with Eclipse

To continue my last post , launching a Lift program and debugging from Eclipse turns out to be straightforward. The starting point was this stackoverlow thread which pointed out the existence of the RunJettyRun Eclipse plugin , which can launch a Jetty instance from within Eclipse configured for remote debugging. Here are the steps to get launching and debugging working seamlessly: Install RunJettyRun from within Eclipse the usual way, ie. menu Help > Install New Software, then copy-paste this link . Once installed, go to menu Run > Debug Configurations, and double-click Jetty Webapp. This will create a new configuration for this project. Click Apply to save this configuration, and you can now start debugging to your heart's content. NOTE: running Jetty in SBT via ~container:start puts the web app in the root of the web server, ie. http://localhost:8080/ , but this plugin defaults to http://localhost:8080/project_name . You can change this via the "Context"

Getting Started with Scala Web Development - Lift 2.4 and SBT 0.11.2

Anyone following this blog knows I do most of my development in C#, but I recently had an opportunity for a Java project, so I'm taking the Scala plunge with Lift . It's been a bit of a frustrating experience so far since all of the documentation on any Java web framework assumes prior experience with Java servlets or other Java web frameworks. Just a note, I'm not intending to bash anything, but I will point out some serious flaws in the tools or documentation that I encountered which seriously soured me on these tools. This is not a reason to get defensive, but it's an opportunity to see how accessible these tools are to someone with little bias or background in this environment. In this whole endeavour, it was most frustrating trying to find a coherent explanation of the directory structures used by various build tools, JSPs and WARs. I finally managed to find a good intro for Lift that didn't assume I already knew how files are organized, and that started

Oh C#, why must you make life so difficult?

Ran into a problem with C#'s implicit conversions, which don't seem to support generic types: class Foo<T> { public T Value { get; set; } public static implicit operator Foo<T>(T value) { return new Foo<T> { Value = value }; } } static class Program { static void Main(string[] args) { // this is fine: Foo<IEnumerable<int>> x = new int[0]; // this is not fine: Foo<IEnumerable<int>> y = Enumerable.Empty<int>(); //Error 2: Cannot implicitly convert type 'IEnumerable<int>' //to 'Foo<IEnumerable<int>>'. An explicit conversion //exists (are you missing a cast? } } So basically, you can't implicitly convert nested generic types, but implicit array conversions work just fine.