Re: [akka-user] How to call a Future-based test from a Route?

2016-12-31 Thread Alan Burlison
> Have you seen the complete list of directives?
> There's many directives with "Async" that means that they work on Futures.

I've seen the async authorization directives but none of them fit the
header mechanism I'm trying to emulate.
authenticateOrRejectWithChallenge() seems to come closest but on
failure I don't want a challenge response, just a rejection.

I see onComplete() takes a future which looks closer to what I want
but how you'd combine an authenticateBasicAsync with two other
Future-based custom authentication mechanisms so that you get a single
result or a rejection is completely unclear to me.

I must say that I'm finding the high level Akka-HTTP API rather
difficult to use, for simple cases it all looks so easy but as soon as
you step outside of that it immediately gets incredibly complicated
:-/

--
Alan Burlison
--

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] How to call a Future-based test from a Route?

2016-12-31 Thread Konrad Malawski
Have you seen the complete list of directives?
There's many directives with "Async" that means that they work on Futures.

http://doc.akka.io/docs/akka-http/10.0.1/scala/http/routing-dsl/directives/alphabetically.html


-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 31 December 2016 at 13:02:42, Alan Burlison (alan.burli...@gmail.com)
wrote:

I need to provide a REST service that provides HTTP header based
authentication as well as standard Basic HTTP authentication. There
are two header-based mechanisms, one uses a user/pass header pair and
the other uses a session header. I'm struggling to figure out how to
combine all three authentication mechanisms so that I have one
directive that provides the authenticated user id on success and a
rejection otherwise. I can extract the headers fine with
headerValueByName() but I need to do the authentication check
asynchronously with a Future as it might block. I can't find any
directives that look like they take a Future, are there any? The
skeleton I have so far is:

authenticateBasic(null, authenticate) { user => complete(s"Basic: $user") }
~
(headerValueByName("X-Auth-User") & headerValueByName("X-Auth-Key")) {
(user, pass) => complete(s"X-Auth: $user") } ~
headerValueByName("X-Auth-Session") { session => complete(s"Session:
$session")

What's missing for the second two is the actual validation of the
user/pass or token.

Thanks,

-- 
Alan Burlison
-- 

-- 
>> Read the docs: http://akka.io/docs/
>> Check the FAQ:
http://doc.akka.io/docs/akka/current/additional/faq.html
>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups
"Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] How to call a Future-based test from a Route?

2016-12-31 Thread Alan Burlison
I need to provide a REST service that provides HTTP header based
authentication as well as standard Basic HTTP authentication. There
are two header-based mechanisms, one uses a user/pass header pair and
the other uses a session header. I'm struggling to figure out how to
combine all three authentication mechanisms so that I have one
directive that provides the authenticated user id on success and a
rejection otherwise. I can extract the headers fine with
headerValueByName() but I need to do the authentication check
asynchronously with a Future as it might block. I can't find any
directives that look like they take a Future, are there any? The
skeleton I have so far is:

authenticateBasic(null, authenticate) { user => complete(s"Basic: $user") } ~
(headerValueByName("X-Auth-User") & headerValueByName("X-Auth-Key")) {
(user, pass) => complete(s"X-Auth: $user") } ~
headerValueByName("X-Auth-Session") { session => complete(s"Session: $session")

What's missing for the second two is the actual validation of the
user/pass or token.

Thanks,

-- 
Alan Burlison
--

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.