-
Notifications
You must be signed in to change notification settings - Fork 478
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
imlement issue #449 : support for Basic Authentication
- Loading branch information
Showing
5 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.influxdb.impl; | ||
|
||
import java.io.IOException; | ||
|
||
import okhttp3.Credentials; | ||
import okhttp3.Interceptor; | ||
import okhttp3.Request; | ||
import okhttp3.Response; | ||
|
||
public class BasicAuthInterceptor implements Interceptor { | ||
|
||
private String credentials; | ||
|
||
public BasicAuthInterceptor(final String user, final String password) { | ||
credentials = Credentials.basic(user, password); | ||
} | ||
|
||
@Override | ||
public Response intercept(final Chain chain) throws IOException { | ||
Request request = chain.request(); | ||
Request authenticatedRequest = request.newBuilder().header("Authorization", credentials).build(); | ||
return chain.proceed(authenticatedRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters