Skip to content

Auth support #14

Closed
Closed
@nedtwigg

Description

@nedtwigg

Blowdryer is predicated on the idea of URL whose content is immutable -> byte[]. When adding auth support, you want to be sure of two things:

  1. the content from a URL shouldn't change because of an auth token, it should just turn a 403 error into a successful download
  2. you don't want to pass an auth token from one service to anywhere else

With that in mind, here is where all downloads happen.

private static void download(String url, File dst) throws IOException {
OkHttpClient client = new OkHttpClient.Builder().build();
Request req = new Request.Builder().url(url).build();
try (Response response = client.newCall(req).execute()) {

To add auth for any given service, you'll want to add a method to BlowdryerSetup with a name like githubAuth(String authToken) or something along those lines. Inside that method, you'll want to call Blowdryer.setAuthPlugin (new method). And then inside of download, you'll use that auth plugin to modify the request based on the URL. I'm not exactly sure what that auth plugin should do, but I think it should probably be something like Request authFor(String url, Request req).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpr-welcomeExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions