rambleraptor commented on code in PR #579:
URL: https://github.com/apache/iceberg-go/pull/579#discussion_r2604140220


##########
catalog/rest/auth.go:
##########
@@ -0,0 +1,141 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package rest
+
+import (
+       "encoding/json"
+       "fmt"
+       "net/http"
+       "net/url"
+       "strings"
+)
+
+// AuthManager is an interface for providing custom authorization headers.
+type AuthManager interface {
+       // AuthHeader returns the key and value for the authorization header.
+       AuthHeader() (string, string, error)
+}
+
+type oauthTokenResponse struct {
+       AccessToken  string `json:"access_token"`
+       TokenType    string `json:"token_type"`
+       ExpiresIn    int    `json:"expires_in"`
+       Scope        string `json:"scope"`
+       RefreshToken string `json:"refresh_token"`
+}
+
+type oauthErrorResponse struct {
+       Err     string `json:"error"`
+       ErrDesc string `json:"error_description"`
+       ErrURI  string `json:"error_uri"`
+}
+
+func (o oauthErrorResponse) Unwrap() error { return ErrOAuthError }
+func (o oauthErrorResponse) Error() string {
+       msg := o.Err
+       if o.ErrDesc != "" {
+               msg += ": " + o.ErrDesc
+       }
+
+       if o.ErrURI != "" {
+               msg += " (" + o.ErrURI + ")"
+       }
+
+       return msg
+}
+
+// Oauth2AuthManager is an implementation of the AuthManager interface which
+// simply returns the provided token as a bearer token. If a credential
+// is provided instead of a static token, it will fetch and refresh the
+// token as needed.
+type Oauth2AuthManager struct {

Review Comment:
   I think that would be a good idea. The eventual idea is that there will be 
multiple AuthManagers + people can choose between them. It seems a little 
strange to have one of them not exported.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to