We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Please include the following file in the sourcecode to allow users to set credentials:
import akka.http.scaladsl.model.headers.Authorization import io.grpc.{CallCredentials, Metadata, Status} import java.util.concurrent.Executor import scala.util.{Failure, Success, Try} object AuthorizationCallCredentials { import io.grpc.Metadata.ASCII_STRING_MARSHALLER val AuthKey: Metadata.Key[String] = Metadata.Key.of("Authorization", ASCII_STRING_MARSHALLER); } final case class AuthorizationCallCredentials(auth: Authorization) extends CallCredentials { override def applyRequestMetadata( requestInfo: CallCredentials.RequestInfo, appExecutor: Executor, metadataApplier: CallCredentials.MetadataApplier): Unit = // implemented similar to official example from: // https://github.com/grpc/grpc-java/blob/master/examples/example-jwt-auth/src/main/java/io/grpc/examples/jwtauth/JwtCredential.java appExecutor.execute { () => val headers = new Metadata() headers.put(AuthorizationCallCredentials.AuthKey, auth.credentials.scheme() + " " + auth.credentials.token()) Try(metadataApplier.apply(headers)) match { case Failure(ex) => metadataApplier.fail(Status.UNAUTHENTICATED.withCause(ex)) case Success(_) => () } } override def thisUsesUnstableApi(): Unit = () }
This allows to set any credential type that is already supported by Akka-HTTP, e.g. like
private val cred = Authorization( BasicHttpCredentials( config.getString("clients.timeseries.username"), config.getString("clients.timeseries.password") )) val grpcClientSettings = GrpcClientSettings.connectToServiceAt(host, port)(akka).withCallCredentials(AuthorizationCallCredentials(cred)))
Mentioning it, e.g. somewhere close to https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html#example-authentication-authorization would probably also be helpful.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Please include the following file in the sourcecode to allow users to set credentials:
This allows to set any credential type that is already supported by Akka-HTTP, e.g. like
Mentioning it, e.g. somewhere close to https://doc.akka.io/docs/akka-grpc/current/server/akka-http.html#example-authentication-authorization would probably also be helpful.
The text was updated successfully, but these errors were encountered: