-
-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support links behind auth #86
Comments
To do this right, we might want to support more than just GitHub's token-based auth. But for an initial PoC, it's a great idea. Would you just add a header to Typhoeus? |
For sure! I guess GitHub's system is the one I'm most familiar with. I have no idea what other links on other sites might be, but I'm happy to work out something more flexible.
Ideally, yeah. A |
Maybe :domain_auth => { "github.com" => {
:type => :header,
:template => "Bearer %token%",
:values => {
:token => ENV['MACHINE_USER_TOKEN']
}
} } So then for basic auth: :domain_auth => { "oldsite.com" => {
:type => :basic,
:values => {
:username => ENV['MACHINE_USERNAME'],
:password => ENV['MACHINE_PASSWORD']
}
} } |
Dang, that's swell. |
Could also use ERB... :) |
What's that? I know you're not talking about Rails templates.... |
ERB is in Ruby's standard library. I mean for the :template => "Bearer <%= @token %>" |
@parkr Is it sufficient to document this use case (maybe in a wiki page) and invite users to use the Ruby / manual Typhoeus configuration approach. This will allow us to close the issue without any code changes and also help people that want to do this. |
That seems like a good idea! I don't have commit rights to this repo, so I won't be able to merge your contribution. But I support the idea 😄 |
Related issues: #427 |
@parkr Thanks for the reply. We have gotten a wiki up and I created this page https://github.com/gjtorikian/html-proofer/wiki/How-to-configure-Typhoeus Would you be able to assist with adding a section for the Typhoeus customization discussed here? |
I added the existing examples here to https://github.com/gjtorikian/html-proofer/wiki/How-to-configure-Typhoeus It is incomplete but should be useful if anyone wants to start there and learn more. |
There is one thing I don't feel is quite clear with the documentation. Is Nested{
:typhoeus => {
:domain_auth => {
"github.com" => {
:type => :header, :template => "Bearer %token%", :values => {
:token => ENV['MACHINE_USER_TOKEN']
}
}
}
}
} Top-level{
:domain_auth => {
"github.com" => {
:type => :header, :template => "Bearer %token%", :values => {
:token => ENV['MACHINE_USER_TOKEN']
}
}
}
} |
Seems like I figured out that nesting Ethon::Errors::InvalidOption:
The option: domain_auth is invalid.
# /Users/bitbear/gems/gems/ethon-0.12.0/lib/ethon/easy.rb:238:in `block in set_attributes'
# /Users/bitbear/gems/gems/ethon-0.12.0/lib/ethon/easy.rb:235:in `each_pair'
# /Users/bitbear/gems/gems/ethon-0.12.0/lib/ethon/easy.rb:235:in `set_attributes'
# /Users/bitbear/gems/gems/ethon-0.12.0/lib/ethon/easy/http/actionable.rb:99:in `setup'
# /Users/bitbear/gems/gems/ethon-0.12.0/lib/ethon/easy/http/head.rb:17:in `setup'
# /Users/bitbear/gems/gems/ethon-0.12.0/lib/ethon/easy/http.rb:39:in `http_request'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/easy_factory.rb:81:in `get'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/addable.rb:19:in `add'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/memoizable.rb:41:in `add'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/cacheable.rb:10:in `add'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/block_connection.rb:30:in `add'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/stubbable.rb:23:in `add'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/before.rb:27:in `add'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/queueable.rb:77:in `dequeue_many'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/runnable.rb:14:in `run'
# /Users/bitbear/gems/gems/typhoeus-1.4.0/lib/typhoeus/hydra/memoizable.rb:51:in `run'
# /Users/bitbear/gems/gems/html-proofer-3.15.3/lib/html-proofer/url_validator.rb:106:in `external_link_checker'
# /Users/bitbear/gems/gems/html-proofer-3.15.3/lib/html-proofer/url_validator.rb:31:in `run'
# /Users/bitbear/gems/gems/html-proofer-3.15.3/lib/html-proofer/runner.rb:120:in `validate_urls'
# /Users/bitbear/gems/gems/html-proofer-3.15.3/lib/html-proofer/runner.rb:82:in `check_files'
# /Users/bitbear/gems/gems/html-proofer-3.15.3/lib/html-proofer/runner.rb:42:in `run' However, moving |
This is weird. I can't find any mention of |
@asbjornu To be honest this issue is so old I had to investigate myself. For your specific case, it would seem that just providing the headers would work:
|
Thanks for clarifying and for the provided code example, @gjtorikian! The problem with adding a static If it's possible to build something like that by extending HTMLProofer somehow, I wouldn't mind solving this myself, but I'm not familiar enough with HTMLProofer's codebase to know where to plug in such functionality. Could you please provide some pointers if this is possible to do (outside of HTMLProofer's codebase) at all? |
A simpler and more general-purpose design than the one proposed in #86 (comment) could perhaps be something like this: runner = HTMLProofer.check_directory('./out')
runner.before_request do |request|
# request is a Typhoeus::Request object
if request.base_url == 'https://github.com'
request.options[:headers]['Authorization'] = "Bearer #{ENV['MACHINE_USER_TOKEN']}"
end
end
runner.run Then the host validation is up to the user of HTMLProofer, providing more flexibility as well as providing less complexity to the HTMLProofer codebase. Thoughts? |
I think that’s pretty great, actually! If you have the time I’d definitely accept a PR. At the moment I’m wrapping up a master’s dissertation and couldn’t devote time to this until mid to late September. |
I submitted #577 now with an implementation of the |
Occasionally, at GitHub, we'll link to sites within github.com that are behind auth. For example:
[check out this discussion](https://www.github.com/github/secret-internal-repo/issues/23)
.We've had to exclude these links by writing them out as HTML and adding
data-proofer-ignore
. Blah.I think instead there should be a new config option hash that takes a domain as a key, and an OAuth token as the value, so that these sorts of links can be checked. For example, you'd pass in
:domain_auth => { "github.com" => ENV['MACHINE_USER_TOKEN'] }
. When HTML::Proofer hits a 404, it'd look the domain up, and try to use the provided token to recheck the link./cc @penibelst @parkr Y'all think this makes sense?
The text was updated successfully, but these errors were encountered: