Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

Username/Password #94

Closed
dcmcshan opened this issue Feb 1, 2017 · 6 comments
Closed

Username/Password #94

dcmcshan opened this issue Feb 1, 2017 · 6 comments

Comments

@dcmcshan
Copy link

dcmcshan commented Feb 1, 2017

Is there a way to specify username/password for the endpoint?

Thanks!

@LaurensRietveld
Copy link
Contributor

LaurensRietveld commented Feb 1, 2017

I suppose you mean an endpoint that is secured by basic authentication?
I tried to solve this issue in a generic fashion here (TriplyDB/Yasgui#45), but failed to.
However, if you're planning to deploy yasqe on one endpoint specifically, and you control the endpoint as well as the YASQE page, this should be possible.

If you're in a position where you can hardcode the username/password in JS, you can simply set the Authorization header via this YASQE config:

{
  sparql: { 
    headers: { 
      Authorization: '<base encoded credentials>'
     }
  }
}

If you'd like to present something like a popup, it should be possible as well, by setting:

{
  sparql:
    xhrFields: {
      withCredentials: true
    }
  }
}

You may need to update your endpoint as well, as JS requests over basic auth are not allowed when the endpoint has a wildcard CORS setting. (you'll notice that soon enough when the above setting results in network errors in your browser developer toolbar)

@dcmcshan
Copy link
Author

dcmcshan commented Feb 2, 2017 via email

@LaurensRietveld
Copy link
Contributor

What are the message you see in your browser toolbar? For both methods there should be some network errors (I'm guessing they are CORS related)

@dcmcshan
Copy link
Author

dcmcshan commented Feb 3, 2017 via email

@LaurensRietveld
Copy link
Contributor

That's difficult to say: it can be either Allegrograph or a proxy (if there is any) in between such as nginx or apache.
This should indeed be something the IT guy would be able to fix. I'd point him to this ticket first TriplyDB/Yasgui#45 as this describes the problem a bit better.

In short, there should not be a wildcard cross-domain setting such as Access-Control-Allow-Origin:* as this may cause problems when authenticating using basic oauth. Instead, in something like nginx, you'd set the Acces-Control header based on one of the request headers: add_header 'Access-Control-Allow-Origin' "$http_origin";
This would have the same effect as a wildcard cors header, but you'd avoid the possible authentication issues

@LaurensRietveld
Copy link
Contributor

closing. If there are other issues let me know

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants