Framework-supported programmatic authentication?

16 views
Skip to first unread message

Konstantin

unread,
Mar 2, 2011, 4:17:43 PM3/2/11
to restfulie-dotnet
Hi,

I just joined the group. I am primarily a researcher/educator and am
in the process of using Restfulie in some RMM level 3 demos. I am
happy about the recent progress on the documentation end.

I am not a .NET expert but understand that there is usually container-
based authentication (MembershipProvider). But there are situations
where programmatic authentication is preferable because it might or
might not be required depending on resource state, and the source of
authentication information is usually the resources as well. Here is a
brief example in Scala/Unfiltered. The goal is to expose a user domain
object and require authentication with the credentials stored in the
object but only if the object exists; that is, if /name does not
exist, the result should be a straight 404 instead of a 401.

case r @ GET(Path(Seg(name :: Nil))) => {
userRepository.findByName(name) match {
case Some(user) => r match {
case BasicAuth(u, p) if verify(u, p, user) =>
Ok ~> ResponseString(user.toString)
case _ => Unauthorized ~> WWWAuthenticate("""Basic
realm="/""" + name + "\"")
}
case _ => NotFound
}
}

Thanks for any help you can provide.

Konstantin

Mauricio Aniche

unread,
Mar 4, 2011, 9:26:14 AM3/4/11
to restfuli...@googlegroups.com, klae...@gmail.com
Hi Konstantin,

Sorry for the slow reply.

Restfulie.NET currently does not support Unauthorized result. However,
implementing it is a piece of cake. You can found some results
implementation here:
https://github.com/mauricioaniche/restfulie.net/tree/master/Restfulie.Server/Results

If you want us to implement, just let me know what you need for this
result and I do it for you!

Regards,
Mauricio

Konstantin Läufer

unread,
Mar 5, 2011, 3:04:40 PM3/5/11
to Mauricio Aniche, restfuli...@googlegroups.com
Muito obrigado, Mauricio. 

This was going to be an example for the class I am teaching, so it is not in any critical path. So please do not go out of your way to work on this feature. I will at some point check out your work on results. Part of my problem might be that I am using Mono, which might not support container-based authentication properly either.

For now, I will stick mostly with Scala + Unfiltered for my class.

Thanks again!

Konstantin

Guilherme Silveira

unread,
Mar 6, 2011, 4:59:38 AM3/6/11
to restfulie-dotnet, Konstantin Läufer, Mauricio Aniche
Hi Konstantin,

If you are using Scala through Unfiltered for the server side, you
might want to take a look at VRaptor using Scala:
http://vraptor.caelum.com.br/documentation/scala/

The example is pretty simple but it supports everything that Restfulie
java supports (it is the same code base). There is also a mydvds
application written in scala to showcase its usage.

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Konstantin Läufer

unread,
Mar 7, 2011, 9:31:33 AM3/7/11
to restfuli...@googlegroups.com, Guilherme Silveira, Mauricio Aniche
Hi Guilherme,

Thanks for the suggestion. The first thing that comes to mind that we should probably add a row for VRaptor to implementing-rest indicating support for Java and Scala. Do you agree? If you're busy, I can do that and create a stub page. Perhaps you can later fill in the details on the features such as content negotiation etc.

Regarding VRaptor's Scala support, I am confident that it is mature and effective. But my needs are more teaching-focused, and I really like the way Unfiltered takes advantage of functional language features such as pattern matching (request extractors) and higher-order functions (response combinators).

Regards,

Guilherme Silveira

unread,
Mar 9, 2011, 7:22:01 AM3/9/11
to restfulie-dotnet
> Do you agree? If you're busy, I can do that and create a
> stub page. Perhaps you can later fill in the details on the features such as
> content negotiation etc.
Yep. That would be perfect! You can get the vraptor doc stub fromthe
project itself (there is a vraptor-site project within it)

> Regarding VRaptor's Scala support, I am confident that it is mature and
> effective. But my needs are more teaching-focused, and I really like the way
> Unfiltered takes advantage of functional language features such as pattern
> matching (request extractors) and higher-order functions (response
> combinators).

Yep... while in the OO vraptor support we use polimorphism through
interfaces (request extractors) and interceptor composition (response
combinators). Makes total sense... I really like how functions can be
easily combined to compose behavior.. it requires all of them having
adapting interfaces, of course (i.e. all with the same input/output,
or matching ones)

Regards


Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Konstantin Läufer

unread,
Mar 10, 2011, 12:00:25 PM3/10/11
to restfuli...@googlegroups.com, Guilherme Silveira
OK, great, I added the row and a stub page based on the one-minute guide.


Could you please help with RMM, conneg, conditional, and cache? RMM is obviously at least 2, but I could not find anything in the VRaptor documentation on relations or links the way Restfulie handles them.

Regards,

Konstantin

Guilherme Silveira

unread,
Mar 10, 2011, 1:37:24 PM3/10/11
to Konstantin Läufer, restfuli...@googlegroups.com
Hi Konstantin!

I just found the basic example, its in the restfulie docs (wiki):
https://github.com/caelum/restfulie-java/wiki/java_one_minute

What do you think?

Regards

Guilherme Silveira
Caelum | Ensino e Inovação
http://www.caelum.com.br/

Konstantin Läufer

unread,
Mar 25, 2011, 9:32:23 PM3/25/11
to restfuli...@googlegroups.com, Guilherme Silveira
It definitely looks like it is at the right level of abstraction! I will take a closer look at some point.

Best regards,

Konstantin
Reply all
Reply to author
Forward
0 new messages