Merge branch 'bugfix/code_challenge_method' into develop
/ docker (push) Successful in 1m55s
Details
/ docker (push) Successful in 1m55s
Details
This commit is contained in:
commit
8bc3a67281
|
@ -8,6 +8,7 @@ import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash"
|
"hash"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -36,7 +37,7 @@ var (
|
||||||
|
|
||||||
var ErrCodeChallengeMethodUnknown error = NewError(
|
var ErrCodeChallengeMethodUnknown error = NewError(
|
||||||
ErrorCodeInvalidRequest,
|
ErrorCodeInvalidRequest,
|
||||||
"unknown code_challene_method",
|
"unknown code_challenge_method",
|
||||||
"https://indieauth.net/source/#authorization-request",
|
"https://indieauth.net/source/#authorization-request",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -61,27 +62,30 @@ func ParseCodeChallengeMethod(uid string) (CodeChallengeMethod, error) {
|
||||||
|
|
||||||
// UnmarshalForm implements custom unmarshler for form values.
|
// UnmarshalForm implements custom unmarshler for form values.
|
||||||
func (ccm *CodeChallengeMethod) UnmarshalForm(v []byte) error {
|
func (ccm *CodeChallengeMethod) UnmarshalForm(v []byte) error {
|
||||||
method, err := ParseCodeChallengeMethod(string(v))
|
parsed, err := ParseCodeChallengeMethod(string(v))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("CodeChallengeMethod: UnmarshalForm: %w", err)
|
return fmt.Errorf("CodeChallengeMethod: UnmarshalForm: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
*ccm = method
|
*ccm = parsed
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalJSON implements custom unmarshler for JSON.
|
// UnmarshalJSON implements custom unmarshler for JSON.
|
||||||
func (ccm *CodeChallengeMethod) UnmarshalJSON(v []byte) error {
|
func (ccm *CodeChallengeMethod) UnmarshalJSON(v []byte) error {
|
||||||
src, err := strconv.Unquote(string(v))
|
unquoted, err := strconv.Unquote(string(v))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("CodeChallengeMethod: UnmarshalJSON: %w", err)
|
return fmt.Errorf("CodeChallengeMethod: UnmarshalJSON: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if *ccm, err = ParseCodeChallengeMethod(src); err != nil {
|
parsed, err := ParseCodeChallengeMethod(unquoted)
|
||||||
|
if err != nil && !errors.Is(err, ErrCodeChallengeMethodUnknown) {
|
||||||
return fmt.Errorf("CodeChallengeMethod: UnmarshalJSON: %w", err)
|
return fmt.Errorf("CodeChallengeMethod: UnmarshalJSON: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*ccm = parsed
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue