You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/16 04:47:58 UTC

[GitHub] [pulsar-client-go] tisonkun commented on a diff in pull request #883: Add data url format to read the key file

tisonkun commented on code in PR #883:
URL: https://github.com/apache/pulsar-client-go/pull/883#discussion_r1023500127


##########
oauth2/client_credentials_provider.go:
##########
@@ -55,8 +56,17 @@ func (k *KeyFileProvider) GetClientCredentials() (*KeyFile, error) {
 	case strings.HasPrefix(k.KeyFile, FILE):
 		filename := strings.TrimPrefix(k.KeyFile, FILE)
 		keyFile, err = ioutil.ReadFile(filename)
-	case strings.HasPrefix(k.KeyFile, "data://"):
+	case strings.HasPrefix(k.KeyFile, DATA):
 		keyFile = []byte(strings.TrimPrefix(k.KeyFile, DATA))
+	case strings.HasPrefix(k.KeyFile, "data:"):
+		url, err := newDataURL(k.KeyFile)
+		if err != nil {
+			return nil, err
+		}
+		if url.Mimetype != "application/json" {

Review Comment:
   Shall we relax the restriction here but let the following `json.Unmarshal` to throw error if users don't specify `Mimetype` but actually parse a valid JSON payload?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org