mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-19 06:00:40 -04:00
ci: adjust code for sonarcloud issues
This commit is contained in:
@@ -4,5 +4,5 @@ import "github.com/golang-jwt/jwt/v4"
|
||||
|
||||
type Claims struct {
|
||||
WopiContext WopiContext `json:"WopiContext"`
|
||||
jwt.StandardClaims
|
||||
jwt.RegisteredClaims
|
||||
}
|
||||
|
||||
@@ -45,6 +45,8 @@ func getAppURLs(wopiAppUrl string, insecure bool, logger log.Logger) (map[string
|
||||
return nil, err
|
||||
}
|
||||
|
||||
defer httpResp.Body.Close()
|
||||
|
||||
if httpResp.StatusCode != http.StatusOK {
|
||||
logger.Error().
|
||||
Str("WopiAppUrl", wopiAppUrl).
|
||||
@@ -53,8 +55,6 @@ func getAppURLs(wopiAppUrl string, insecure bool, logger log.Logger) (map[string
|
||||
return nil, errors.New("status code was not 200")
|
||||
}
|
||||
|
||||
defer httpResp.Body.Close()
|
||||
|
||||
var appURLs map[string]map[string]string
|
||||
|
||||
appURLs, err = parseWopiDiscovery(httpResp.Body)
|
||||
|
||||
@@ -92,7 +92,9 @@ func DownloadFile(
|
||||
// TODO: the access token shouldn't be needed
|
||||
httpReq.Header.Add("X-Access-Token", token)
|
||||
|
||||
httpResp, err := httpClient.Do(httpReq)
|
||||
// TODO: this needs a refactor to comply with the "bodyclose" linter
|
||||
// response body is closed in the caller method for now
|
||||
httpResp, err := httpClient.Do(httpReq) //nolint:bodyclose
|
||||
if err != nil {
|
||||
logger.Error().
|
||||
Err(err).
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
func UploadFile(
|
||||
ctx context.Context,
|
||||
content io.ReadCloser,
|
||||
content io.Reader, // content won't be closed inside the method
|
||||
contentLength int64,
|
||||
ref *providerv1beta1.Reference,
|
||||
gwc gatewayv1beta1.GatewayAPIClient,
|
||||
|
||||
@@ -170,7 +170,7 @@ func (s *Service) OpenInApp(
|
||||
ViewAppUrl: viewAppURL,
|
||||
}
|
||||
|
||||
cs3Claims := &jwt.StandardClaims{}
|
||||
cs3Claims := &jwt.RegisteredClaims{}
|
||||
cs3JWTparser := jwt.Parser{}
|
||||
_, _, err = cs3JWTparser.ParseUnverified(req.AccessToken, cs3Claims)
|
||||
if err != nil {
|
||||
@@ -185,7 +185,7 @@ func (s *Service) OpenInApp(
|
||||
|
||||
claims := &app.Claims{
|
||||
WopiContext: wopiContext,
|
||||
StandardClaims: jwt.StandardClaims{
|
||||
RegisteredClaims: jwt.RegisteredClaims{
|
||||
ExpiresAt: cs3Claims.ExpiresAt,
|
||||
},
|
||||
}
|
||||
@@ -220,7 +220,7 @@ func (s *Service) OpenInApp(
|
||||
// these parameters will be passed to the web server by the app provider application
|
||||
"access_token": accessToken,
|
||||
// milliseconds since Jan 1, 1970 UTC as required in https://docs.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/rest/concepts#access_token_ttl
|
||||
"access_token_ttl": strconv.FormatInt(claims.ExpiresAt*1000, 10),
|
||||
"access_token_ttl": strconv.FormatInt(claims.ExpiresAt.UnixMilli(), 10),
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user