Dano,

That's a good question.
I am looking at using these web services to expose functionality of an
application that is built using the Spring framework (sorry @dpp :-) ).
My default approach is to use Spring Security/Acegi filter to handle
authentication.
And, I would have passed the credentials using either HTTP BasicAuth or as
specially named URL query parameters

Chris


On Tue, Feb 10, 2009 at 2:22 PM, Dano <olearydani...@gmail.com> wrote:

>
> Chris/David,
>
> Thanks very much for the example!
>
> Have you two discussed how to mix authorization into this example?
> When I talked with David about this topic, it seemed that restful
> services couple credentials with the request.
>
> For example, could you use BasicAuth with a username/password as part
> of the URL via https?  If so, how would your example above be changed
> to reflect that?
>
> Thanks in advance.
>
>
> Dan
>
> On Feb 9, 4:51 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> > Chris,
> > Looks like you've been having way too much fun!
> >
> > Thanks,
> >
> > David
> >
> > On Mon, Feb 9, 2009 at 2:01 PM, Chris Richardson <
> >
> >
> >
> > chris.e.richard...@gmail.com> wrote:
> > > Hi,
> >
> > > I just started playing around with Scala and Lift and with @dpp's help
> > > wrote a simple RESTful web service.
> > > I wanted to share the code with this group and get feedback and
> suggestions
> > > about improvements.
> > > See below.
> > > Thanks.
> >
> > > Chris
> >
> > > In Boot.scala you register one or more WsEndpoints (a trait that is
> defined
> > > later).
> >
> > > I was wondering whether Lift has a way to search and register them
> > > automatically?
> >
> > > class Boot {
> >
> > >   def boot {
> >
> > >     val x :List[WsEndpoint] = List(ExampleApi)
> > >     x.foreach ( endpoint => LiftRules.dispatch.append
> > > (endpoint.dispatchRules)  )
> >
> > >   }
> >
> > > }
> >
> > > ----
> >
> > > Here is the class that defines methods that take parameters from the
> HTTP
> > > request and returns XML nodes.
> >
> > > class ExampleApi {
> >
> > >      def doGet(id: String) : Node = {
> > >        <info3 id={id} />
> > >       }
> >
> > > }
> >
> > > The companion object sets up the mapping rules, e.g. /api/item/1 ->
> > > exampleApi.doGet(1)
> >
> > > object ExampleApi extends WsEndpoint {
> >
> > >     val exampleApi = new ExampleApi()
> >
> > >     override def wsDispatchRules  =
> > >         {
> > >           case Req("api" :: "item" :: id :: _, _, GetRequest) => () =>
> > > exampleApi.doGet(id)
> > >         }
> > > }
> >
> > > WsEndpoint is a trait that handles the conversion from what Lift
> expects,
> > > i.e. () => Full[XmlResponse] to what is written above, i.e .() => Node
> >
> > > trait WsEndpoint {
> >
> > >     def wsDispatchRules : PartialFunction[Req,() => Node]
> >
> > >     def dispatchRules : PartialFunction[Req,() => Full[XmlResponse]] =
> {
> > >       new MyAdapter(wsDispatchRules)
> > >     }
> >
> > >     abstract class PartialFunctionAdapter [F, T1, T2] (adaptee:
> > > PartialFunction[F, T1]) extends PartialFunction[F, T2] {
> > >       override def isDefinedAt(r : F) = adaptee.isDefinedAt(r)
> >
> > >       override def apply(r : F)  = {
> > >         converter(adaptee.apply(r))
> > >       }
> >
> > >       def converter (x : T1) : T2
> >
> > >     }
> >
> > >     class MyAdapter(adaptee: PartialFunction[Req, () => Node])
> > >         extends PartialFunctionAdapter[Req, () => Node, () =>
> > > Full[XmlResponse] ](adaptee)   {
> >
> > >        override def converter (x : () => Node)  = {
> > >         () => Full(XmlResponse(x()))
> > >        }
> > >     }
> > > }
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to