Rename AuthenticationInterceptor => TokenAuthInterceptor

This commit is contained in:
Chris Beams 2020-04-23 10:35:04 +02:00
parent 24c245c2ea
commit ca0658229b
No known key found for this signature in database
GPG Key ID: 3D214F8F5BC5ED73
3 changed files with 5 additions and 5 deletions

View File

@ -28,7 +28,7 @@ public class BisqCallCredentials extends CallCredentials {
appExecutor.execute(() -> {
try {
Metadata headers = new Metadata();
Key<String> creds = Key.of("bisqd-creds", ASCII_STRING_MARSHALLER);
Key<String> creds = Key.of("bisq-api-token", ASCII_STRING_MARSHALLER);
headers.put(creds, encodeCredentials());
metadataApplier.apply(headers);
} catch (Throwable ex) {

View File

@ -217,7 +217,7 @@ public class BisqGrpcServer {
.addService(new GetPaymentAccountsImpl())
.addService(new PlaceOfferImpl())
.addService(new StopServerImpl())
.intercept(new AuthenticationInterceptor(rpcUser, rpcPassword))
.intercept(new TokenAuthInterceptor(rpcUser, rpcPassword))
.build()
.start();

View File

@ -16,12 +16,12 @@ import static io.grpc.Status.UNAUTHENTICATED;
* Simple authentication interceptor to validate a cleartext token in username:password format.
*/
@Slf4j
public class AuthenticationInterceptor implements ServerInterceptor {
public class TokenAuthInterceptor implements ServerInterceptor {
private final String rpcUser;
private final String rpcPassword;
public AuthenticationInterceptor(String rpcUser, String rpcPassword) {
public TokenAuthInterceptor(String rpcUser, String rpcPassword) {
this.rpcUser = rpcUser;
this.rpcPassword = rpcPassword;
}
@ -29,7 +29,7 @@ public class AuthenticationInterceptor implements ServerInterceptor {
@Override
public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(ServerCall<ReqT, RespT> serverCall, Metadata metadata,
ServerCallHandler<ReqT, RespT> serverCallHandler) {
authenticate(metadata.get(Key.of("bisqd-creds", ASCII_STRING_MARSHALLER)));
authenticate(metadata.get(Key.of("bisq-api-token", ASCII_STRING_MARSHALLER)));
return serverCallHandler.startCall(serverCall, metadata);
}