Simplifiy Unmarshall function for stringAsBool struct

Co-authored-by: Julian Koberg <jkoberg@owncloud.com>
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
Christian Richter
2023-04-20 11:27:21 +02:00
parent 7b1be941b7
commit a6ced1f99f
2 changed files with 5 additions and 8 deletions

View File

@@ -10,6 +10,7 @@ import (
"io"
"mime"
"net/http"
"strconv"
"strings"
"sync"
"time"
@@ -176,14 +177,11 @@ type stringAsBool bool
// Claims unmarshals the raw JSON string into a bool.
func (sb *stringAsBool) UnmarshalJSON(b []byte) error {
switch string(b) {
case "true", `"true"`:
*sb = true
case "false", `"false"`:
*sb = false
default:
return errors.New("invalid value for boolean")
v, err := strconv.ParseBool(string(b))
if err != nil {
return err
}
*sb = stringAsBool(v)
return nil
}

View File

@@ -70,7 +70,6 @@ func (m *OIDCAuthenticator) getClaims(token string, req *http.Request) (map[stri
m.Logger.Error().Err(err).Msg("could not unmarshal userinfo")
}
// TODO: use mClaims
aClaims, _, err := m.oidcClient.VerifyAccessToken(req.Context(), token)
if err != nil {
return nil, errors.Wrap(err, "failed to verify access token")