next-drupal icon indicating copy to clipboard operation
next-drupal copied to clipboard

How to configure HTTP credentials while using OAuth authentication?

Open mikaelkundert opened this issue 2 years ago • 9 comments

In our testing environments we tend to hide our Drupal from public internet, so it wont disclosure anything or get indexed by Google.

While eventually we want to use OAuth authentication, we want to use additionally HTTP authentication. How do we inject in our credentials in NextJS side?

We tried already by setting our base domains with https://username:[email protected] which didn't work out.

Thanks!

mikaelkundert avatar Apr 13 '22 14:04 mikaelkundert

Have you looked into using the password grant? https://next-drupal.org/docs/authentication/password-grant

shadcn avatar Apr 13 '22 14:04 shadcn

I'll chime in here as I work in the project with @mikaelkundert.

So the problem in our case is on server side. For example when getPathsFromContext() is fetching data from JSON:API - it can't get past Drupal's basic auth.

In the deployed environments it's easy to allow server to server communication past basic auth, but we are doing builds in Circle CI and that gets a bit tricky.

By the way, Thanks for this amazing project!

juhov avatar Apr 14 '22 05:04 juhov

@juhov I see. Would a pluggable auth system solve your issue? As in bring your own auth headers?

shadcn avatar Apr 14 '22 05:04 shadcn

That sound good. But is it a problem that next-drupal and our custom header collide? In this basic auth case we would need to add Authorization: Basic <credentials> and next-drupal will add Authorization: Bearer <token>.

juhov avatar Apr 14 '22 06:04 juhov

According to this StackOverflow answer, supporting multiple authorization schemes is not supported.

I think we might need to do some tricks in our Drupal hosting side, to partially use Bearer scheme on some URL's and Basic scheme on rest of the URL's :thinking:

The idea of using combined schemes for one request seems to be doomed idea. What do you think?

mikaelkundert avatar Apr 14 '22 07:04 mikaelkundert

@mikaelkundert @juhov are you on Drupal Slack? Can we chat say in 30 minutes?

shadcn avatar Apr 14 '22 07:04 shadcn

Yeah sure, I'm on it. Not sure about @juhov.

mikaelkundert avatar Apr 14 '22 08:04 mikaelkundert

Hola!

Did you manage to get around this somehow? Interested in the same question :)

eiriksm avatar May 11 '22 12:05 eiriksm

@eiriksm We added support for basic auth to the DrupalClient. See https://next-drupal.org/docs/client/auth

shadcn avatar May 11 '22 12:05 shadcn