parent
9ae703fe51
commit
dc79c8ea59
|
@ -79,7 +79,7 @@ func docsDateRunE(cmd *cobra.Command, args []string) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
frontmatter := map[string]interface{}{}
|
||||
frontmatter := map[string]any{}
|
||||
|
||||
if err = yaml.Unmarshal(frontmatterBytes, frontmatter); err != nil {
|
||||
return err
|
||||
|
|
|
@ -168,8 +168,8 @@ func pnpmInstall() {
|
|||
shell(fmt.Sprintf("cd %s/web && pnpm install", cwd))
|
||||
}
|
||||
|
||||
func bootstrapPrintln(args ...interface{}) {
|
||||
a := make([]interface{}, 0)
|
||||
func bootstrapPrintln(args ...any) {
|
||||
a := make([]any, 0)
|
||||
a = append(a, "[BOOTSTRAP]")
|
||||
a = append(a, args...)
|
||||
fmt.Println(a...)
|
||||
|
|
|
@ -21,7 +21,7 @@ type DockerImages []DockerImage
|
|||
// DockerImage represents some of the data from the docker images API.
|
||||
type DockerImage struct {
|
||||
Architecture string `json:"architecture"`
|
||||
Variant interface{} `json:"variant"`
|
||||
Variant any `json:"variant"`
|
||||
Digest string `json:"digest"`
|
||||
OS string `json:"os"`
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ func NewExtendedSearchRequestMatcher(filter, base string, scope, derefAliases in
|
|||
return &ExtendedSearchRequestMatcher{filter, base, scope, derefAliases, typesOnly, attributes}
|
||||
}
|
||||
|
||||
func (e *ExtendedSearchRequestMatcher) Matches(x interface{}) bool {
|
||||
func (e *ExtendedSearchRequestMatcher) Matches(x any) bool {
|
||||
sr := x.(*ldap.SearchRequest)
|
||||
|
||||
if e.filter != sr.Filter || e.baseDN != sr.BaseDN || e.scope != sr.Scope || e.derefAliases != sr.DerefAliases ||
|
||||
|
@ -502,7 +502,7 @@ func NewSearchRequestMatcher(expected string) *SearchRequestMatcher {
|
|||
return &SearchRequestMatcher{expected}
|
||||
}
|
||||
|
||||
func (srm *SearchRequestMatcher) Matches(x interface{}) bool {
|
||||
func (srm *SearchRequestMatcher) Matches(x any) bool {
|
||||
sr := x.(*ldap.SearchRequest)
|
||||
return sr.Filter == srm.expected
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ func newCryptoGenerateCmd(category, algorithm string) (cmd *cobra.Command) {
|
|||
|
||||
func cryptoGenerateRunE(cmd *cobra.Command, args []string) (err error) {
|
||||
var (
|
||||
privateKey interface{}
|
||||
privateKey any
|
||||
)
|
||||
|
||||
if privateKey, err = cryptoGenPrivateKeyFromCmd(cmd); err != nil {
|
||||
|
@ -251,7 +251,7 @@ func cryptoGenerateRunE(cmd *cobra.Command, args []string) (err error) {
|
|||
|
||||
func cryptoCertificateRequestRunE(cmd *cobra.Command, _ []string) (err error) {
|
||||
var (
|
||||
privateKey interface{}
|
||||
privateKey any
|
||||
)
|
||||
|
||||
if privateKey, err = cryptoGenPrivateKeyFromCmd(cmd); err != nil {
|
||||
|
@ -320,10 +320,10 @@ func cryptoCertificateRequestRunE(cmd *cobra.Command, _ []string) (err error) {
|
|||
return nil
|
||||
}
|
||||
|
||||
func cryptoCertificateGenerateRunE(cmd *cobra.Command, _ []string, privateKey interface{}) (err error) {
|
||||
func cryptoCertificateGenerateRunE(cmd *cobra.Command, _ []string, privateKey any) (err error) {
|
||||
var (
|
||||
template, caCertificate, parent *x509.Certificate
|
||||
publicKey, caPrivateKey, signatureKey interface{}
|
||||
publicKey, caPrivateKey, signatureKey any
|
||||
)
|
||||
|
||||
if publicKey = utils.PublicKeyFromPrivateKey(privateKey); publicKey == nil {
|
||||
|
@ -412,7 +412,7 @@ func cryptoCertificateGenerateRunE(cmd *cobra.Command, _ []string, privateKey in
|
|||
return nil
|
||||
}
|
||||
|
||||
func cryptoPairGenerateRunE(cmd *cobra.Command, _ []string, privateKey interface{}) (err error) {
|
||||
func cryptoPairGenerateRunE(cmd *cobra.Command, _ []string, privateKey any) (err error) {
|
||||
var (
|
||||
privateKeyPath, publicKeyPath string
|
||||
pkcs8 bool
|
||||
|
@ -451,7 +451,7 @@ func cryptoPairGenerateRunE(cmd *cobra.Command, _ []string, privateKey interface
|
|||
return err
|
||||
}
|
||||
|
||||
var publicKey interface{}
|
||||
var publicKey any
|
||||
|
||||
if publicKey = utils.PublicKeyFromPrivateKey(privateKey); publicKey == nil {
|
||||
return fmt.Errorf("failed to obtain public key from private key")
|
||||
|
|
|
@ -130,7 +130,7 @@ func cryptoGetWritePathsFromCmd(cmd *cobra.Command) (privateKey, publicKey strin
|
|||
return filepath.Join(dir, private), filepath.Join(dir, public), nil
|
||||
}
|
||||
|
||||
func cryptoGenPrivateKeyFromCmd(cmd *cobra.Command) (privateKey interface{}, err error) {
|
||||
func cryptoGenPrivateKeyFromCmd(cmd *cobra.Command) (privateKey any, err error) {
|
||||
switch cmd.Parent().Use {
|
||||
case cmdUseRSA:
|
||||
var (
|
||||
|
@ -170,7 +170,7 @@ func cryptoGenPrivateKeyFromCmd(cmd *cobra.Command) (privateKey interface{}, err
|
|||
return privateKey, nil
|
||||
}
|
||||
|
||||
func cryptoGetCAFromCmd(cmd *cobra.Command) (privateKey interface{}, cert *x509.Certificate, err error) {
|
||||
func cryptoGetCAFromCmd(cmd *cobra.Command) (privateKey any, cert *x509.Certificate, err error) {
|
||||
if !cmd.Flags().Changed(cmdFlagNamePathCA) {
|
||||
return nil, nil, nil
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ func cryptoGetCAFromCmd(cmd *cobra.Command) (privateKey interface{}, cert *x509.
|
|||
|
||||
ok bool
|
||||
|
||||
certificate interface{}
|
||||
certificate any
|
||||
)
|
||||
|
||||
if dir, err = cmd.Flags().GetString(cmdFlagNamePathCA); err != nil {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
func recoverErr(i interface{}) error {
|
||||
func recoverErr(i any) error {
|
||||
switch v := i.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
|
|
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
// StringToMailAddressHookFunc decodes a string into a mail.Address or *mail.Address.
|
||||
func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) {
|
||||
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
|
||||
var ptr bool
|
||||
|
||||
if f.Kind() != reflect.String {
|
||||
|
@ -65,7 +65,7 @@ func StringToMailAddressHookFunc() mapstructure.DecodeHookFuncType {
|
|||
|
||||
// StringToURLHookFunc converts string types into a url.URL or *url.URL.
|
||||
func StringToURLHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) {
|
||||
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
|
||||
var ptr bool
|
||||
|
||||
if f.Kind() != reflect.String {
|
||||
|
@ -111,7 +111,7 @@ func StringToURLHookFunc() mapstructure.DecodeHookFuncType {
|
|||
|
||||
// ToTimeDurationHookFunc converts string and integer types to a time.Duration.
|
||||
func ToTimeDurationHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) {
|
||||
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
|
||||
var ptr bool
|
||||
|
||||
switch f.Kind() {
|
||||
|
@ -172,7 +172,7 @@ func ToTimeDurationHookFunc() mapstructure.DecodeHookFuncType {
|
|||
|
||||
// StringToRegexpHookFunc decodes a string into a *regexp.Regexp or regexp.Regexp.
|
||||
func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) {
|
||||
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
|
||||
var ptr bool
|
||||
|
||||
if f.Kind() != reflect.String {
|
||||
|
@ -218,7 +218,7 @@ func StringToRegexpHookFunc() mapstructure.DecodeHookFuncType {
|
|||
|
||||
// StringToAddressHookFunc decodes a string into an Address or *Address.
|
||||
func StringToAddressHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) {
|
||||
return func(f reflect.Type, t reflect.Type, data any) (value any, err error) {
|
||||
var ptr bool
|
||||
|
||||
if f.Kind() != reflect.String {
|
||||
|
@ -258,7 +258,7 @@ func StringToAddressHookFunc() mapstructure.DecodeHookFuncType {
|
|||
|
||||
// StringToX509CertificateHookFunc decodes strings to x509.Certificate's.
|
||||
func StringToX509CertificateHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return func(f reflect.Type, t reflect.Type, data interface{}) (value interface{}, err error) {
|
||||
return func(f reflect.Type, t reflect.Type, data any) (value interface{}, err error) {
|
||||
if f.Kind() != reflect.String {
|
||||
return data, nil
|
||||
}
|
||||
|
|
|
@ -993,8 +993,8 @@ func TestStringToX509CertificateHookFunc(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
have interface{}
|
||||
want interface{}
|
||||
have any
|
||||
want any
|
||||
err string
|
||||
decode bool
|
||||
}{
|
||||
|
@ -1069,8 +1069,8 @@ func TestStringToX509CertificateChainHookFunc(t *testing.T) {
|
|||
|
||||
testCases := []struct {
|
||||
desc string
|
||||
have interface{}
|
||||
expected interface{}
|
||||
have any
|
||||
expected any
|
||||
err, verr string
|
||||
decode bool
|
||||
}{
|
||||
|
|
|
@ -10,7 +10,7 @@ type Deprecation struct {
|
|||
Key string
|
||||
NewKey string
|
||||
AutoMap bool
|
||||
MapFunc func(value interface{}) interface{}
|
||||
MapFunc func(value any) any
|
||||
ErrText string
|
||||
}
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import (
|
|||
)
|
||||
|
||||
// koanfEnvironmentCallback returns a koanf callback to map the environment vars to Configuration keys.
|
||||
func koanfEnvironmentCallback(keyMap map[string]string, ignoredKeys []string, prefix, delimiter string) func(key, value string) (finalKey string, finalValue interface{}) {
|
||||
return func(key, value string) (finalKey string, finalValue interface{}) {
|
||||
func koanfEnvironmentCallback(keyMap map[string]string, ignoredKeys []string, prefix, delimiter string) func(key, value string) (finalKey string, finalValue any) {
|
||||
return func(key, value string) (finalKey string, finalValue any) {
|
||||
if k, ok := keyMap[key]; ok {
|
||||
return k, value
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ func koanfEnvironmentCallback(keyMap map[string]string, ignoredKeys []string, pr
|
|||
}
|
||||
|
||||
// koanfEnvironmentSecretsCallback returns a koanf callback to map the environment vars to Configuration keys.
|
||||
func koanfEnvironmentSecretsCallback(keyMap map[string]string, validator *schema.StructValidator) func(key, value string) (finalKey string, finalValue interface{}) {
|
||||
return func(key, value string) (finalKey string, finalValue interface{}) {
|
||||
func koanfEnvironmentSecretsCallback(keyMap map[string]string, validator *schema.StructValidator) func(key, value string) (finalKey string, finalValue any) {
|
||||
return func(key, value string) (finalKey string, finalValue any) {
|
||||
k, ok := keyMap[key]
|
||||
if !ok {
|
||||
return "", nil
|
||||
|
@ -50,8 +50,8 @@ func koanfEnvironmentSecretsCallback(keyMap map[string]string, validator *schema
|
|||
}
|
||||
}
|
||||
|
||||
func koanfCommandLineWithMappingCallback(mapping map[string]string, includeValidKeys, includeUnchangedKeys bool) func(flag *pflag.Flag) (string, interface{}) {
|
||||
return func(flag *pflag.Flag) (string, interface{}) {
|
||||
func koanfCommandLineWithMappingCallback(mapping map[string]string, includeValidKeys, includeUnchangedKeys bool) func(flag *pflag.Flag) (string, any) {
|
||||
return func(flag *pflag.Flag) (string, any) {
|
||||
if !includeUnchangedKeys && !flag.Changed {
|
||||
return "", nil
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import (
|
|||
func TestKoanfEnvironmentCallback(t *testing.T) {
|
||||
var (
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
)
|
||||
|
||||
keyMap := map[string]string{
|
||||
|
@ -46,7 +46,7 @@ func TestKoanfEnvironmentCallback(t *testing.T) {
|
|||
func TestKoanfSecretCallbackWithValidSecrets(t *testing.T) {
|
||||
var (
|
||||
key string
|
||||
value interface{}
|
||||
value any
|
||||
)
|
||||
|
||||
keyMap := map[string]string{
|
||||
|
|
|
@ -15,13 +15,13 @@ func koanfGetKeys(ko *koanf.Koanf) (keys []string) {
|
|||
keys = ko.Keys()
|
||||
|
||||
for key, value := range ko.All() {
|
||||
slc, ok := value.([]interface{})
|
||||
slc, ok := value.([]any)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, item := range slc {
|
||||
m, mok := item.(map[string]interface{})
|
||||
m, mok := item.(map[string]any)
|
||||
if !mok {
|
||||
continue
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func koanfRemapKeys(val *schema.StructValidator, ko *koanf.Koanf, ds map[string]
|
|||
return final, nil
|
||||
}
|
||||
|
||||
func koanfRemapKeysStandard(keys map[string]interface{}, val *schema.StructValidator, ds map[string]Deprecation) (keysFinal map[string]interface{}) {
|
||||
func koanfRemapKeysStandard(keys map[string]any, val *schema.StructValidator, ds map[string]Deprecation) (keysFinal map[string]interface{}) {
|
||||
var (
|
||||
ok bool
|
||||
d Deprecation
|
||||
|
|
|
@ -19,7 +19,7 @@ func Load(val *schema.StructValidator, sources ...Source) (keys []string, config
|
|||
}
|
||||
|
||||
// LoadAdvanced is intended to give more flexibility over loading a particular path to a specific interface.
|
||||
func LoadAdvanced(val *schema.StructValidator, path string, result interface{}, sources ...Source) (keys []string, err error) {
|
||||
func LoadAdvanced(val *schema.StructValidator, path string, result any, sources ...Source) (keys []string, err error) {
|
||||
if val == nil {
|
||||
return keys, errNoValidator
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ func LoadAdvanced(val *schema.StructValidator, path string, result interface{},
|
|||
return koanfGetKeys(final), nil
|
||||
}
|
||||
|
||||
func mapHasKey(k string, m map[string]interface{}) bool {
|
||||
func mapHasKey(k string, m map[string]any) bool {
|
||||
if _, ok := m[k]; ok {
|
||||
return true
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func mapHasKey(k string, m map[string]interface{}) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
func unmarshal(ko *koanf.Koanf, val *schema.StructValidator, path string, o interface{}) {
|
||||
func unmarshal(ko *koanf.Koanf, val *schema.StructValidator, path string, o any) {
|
||||
c := koanf.UnmarshalConf{
|
||||
DecoderConfig: &mapstructure.DecoderConfig{
|
||||
DecodeHook: mapstructure.ComposeDecodeHookFunc(
|
||||
|
|
|
@ -145,8 +145,8 @@ func (s *CommandLineSource) Load(_ *schema.StructValidator) (err error) {
|
|||
return s.koanf.Load(posflag.Provider(s.flags, ".", s.koanf), nil)
|
||||
}
|
||||
|
||||
// NewMapSource returns a new map[string]interface{} source.
|
||||
func NewMapSource(m map[string]interface{}) (source *MapSource) {
|
||||
// NewMapSource returns a new map[string]any source.
|
||||
func NewMapSource(m map[string]any) (source *MapSource) {
|
||||
return &MapSource{
|
||||
m: m,
|
||||
koanf: koanf.New(constDelimiter),
|
||||
|
|
|
@ -38,11 +38,11 @@ type SecretsSource struct {
|
|||
type CommandLineSource struct {
|
||||
koanf *koanf.Koanf
|
||||
flags *pflag.FlagSet
|
||||
callback func(flag *pflag.Flag) (string, interface{})
|
||||
callback func(flag *pflag.Flag) (string, any)
|
||||
}
|
||||
|
||||
// MapSource loads configuration from the command line flags.
|
||||
type MapSource struct {
|
||||
m map[string]interface{}
|
||||
m map[string]any
|
||||
koanf *koanf.Koanf
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ func WebauthnAssertionGET(ctx *middlewares.AutheliaCtx) {
|
|||
webauthn.WithAllowedCredentials(user.WebAuthnCredentialDescriptors()),
|
||||
}
|
||||
|
||||
extensions := make(map[string]interface{})
|
||||
extensions := map[string]any{}
|
||||
|
||||
if user.HasFIDOU2F() {
|
||||
extensions["appid"] = w.Config.RPOrigin
|
||||
|
|
|
@ -8,8 +8,8 @@ import (
|
|||
"github.com/authelia/authelia/v4/internal/session"
|
||||
)
|
||||
|
||||
func oidcGrantRequests(ar fosite.AuthorizeRequester, consent *model.OAuth2ConsentSession, userSession *session.UserSession) (extraClaims map[string]interface{}) {
|
||||
extraClaims = map[string]interface{}{}
|
||||
func oidcGrantRequests(ar fosite.AuthorizeRequester, consent *model.OAuth2ConsentSession, userSession *session.UserSession) (extraClaims map[string]any) {
|
||||
extraClaims = map[string]any{}
|
||||
|
||||
for _, scope := range consent.GrantedScopes {
|
||||
if ar != nil {
|
||||
|
|
|
@ -95,7 +95,7 @@ func (ctx *AutheliaCtx) ReplyStatusCode(statusCode int) {
|
|||
}
|
||||
|
||||
// ReplyJSON writes a JSON response.
|
||||
func (ctx *AutheliaCtx) ReplyJSON(data interface{}, statusCode int) (err error) {
|
||||
func (ctx *AutheliaCtx) ReplyJSON(data any, statusCode int) (err error) {
|
||||
var (
|
||||
body []byte
|
||||
)
|
||||
|
@ -246,7 +246,7 @@ func (ctx *AutheliaCtx) ReplyOK() {
|
|||
}
|
||||
|
||||
// ParseBody parse the request body into the type of value.
|
||||
func (ctx *AutheliaCtx) ParseBody(value interface{}) error {
|
||||
func (ctx *AutheliaCtx) ParseBody(value any) error {
|
||||
err := json.Unmarshal(ctx.PostBody(), &value)
|
||||
|
||||
if err != nil {
|
||||
|
@ -267,7 +267,7 @@ func (ctx *AutheliaCtx) ParseBody(value interface{}) error {
|
|||
}
|
||||
|
||||
// SetJSONBody Set json body.
|
||||
func (ctx *AutheliaCtx) SetJSONBody(value interface{}) error {
|
||||
func (ctx *AutheliaCtx) SetJSONBody(value any) error {
|
||||
return ctx.ReplyJSON(OKResponse{Status: "OK", Data: value}, 0)
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ func IdentityVerificationFinish(args IdentityVerificationFinishArgs, next func(c
|
|||
}
|
||||
|
||||
token, err := jwt.ParseWithClaims(finishBody.Token, &model.IdentityVerificationClaim{},
|
||||
func(token *jwt.Token) (interface{}, error) {
|
||||
func(token *jwt.Token) (any, error) {
|
||||
return []byte(ctx.Configuration.JWTSecret), nil
|
||||
})
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ type IdentityVerificationFinishBody struct {
|
|||
// OKResponse model of a status OK response.
|
||||
type OKResponse struct {
|
||||
Status string `json:"status"`
|
||||
Data interface{} `json:"data,omitempty"`
|
||||
Data any `json:"data,omitempty"`
|
||||
}
|
||||
|
||||
// ErrorResponse model of an error response.
|
||||
|
|
|
@ -227,7 +227,7 @@ type OpenIDSession struct {
|
|||
ChallengeID uuid.UUID `db:"challenge_id"`
|
||||
ClientID string
|
||||
|
||||
Extra map[string]interface{} `json:"extra"`
|
||||
Extra map[string]any `json:"extra"`
|
||||
}
|
||||
|
||||
// Clone copies the OpenIDSession to a new fosite.Session.
|
||||
|
|
|
@ -49,7 +49,7 @@ func (ip IP) Value() (value driver.Value, err error) {
|
|||
}
|
||||
|
||||
// Scan is the IP implementation of the sql.Scanner.
|
||||
func (ip *IP) Scan(src interface{}) (err error) {
|
||||
func (ip *IP) Scan(src any) (err error) {
|
||||
if src == nil {
|
||||
return fmt.Errorf(errFmtScanNil, ip)
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ func (ip NullIP) Value() (value driver.Value, err error) {
|
|||
}
|
||||
|
||||
// Scan is the NullIP implementation of the sql.Scanner.
|
||||
func (ip *NullIP) Scan(src interface{}) (err error) {
|
||||
func (ip *NullIP) Scan(src any) (err error) {
|
||||
if src == nil {
|
||||
ip.IP = nil
|
||||
return nil
|
||||
|
@ -128,7 +128,7 @@ func (b Base64) Value() (value driver.Value, err error) {
|
|||
}
|
||||
|
||||
// Scan is the Base64 implementation of the sql.Scanner.
|
||||
func (b *Base64) Scan(src interface{}) (err error) {
|
||||
func (b *Base64) Scan(src any) (err error) {
|
||||
if src == nil {
|
||||
return fmt.Errorf(errFmtScanNil, b)
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ type StartupCheck interface {
|
|||
type StringSlicePipeDelimited []string
|
||||
|
||||
// Scan is the StringSlicePipeDelimited implementation of the sql.Scanner.
|
||||
func (s *StringSlicePipeDelimited) Scan(value interface{}) (err error) {
|
||||
func (s *StringSlicePipeDelimited) Scan(value any) (err error) {
|
||||
var nullStr sql.NullString
|
||||
|
||||
if err = nullStr.Scan(value); err != nil {
|
||||
|
|
|
@ -44,7 +44,7 @@ func TestNewSessionWithAuthorizeRequest(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
extra := map[string]interface{}{
|
||||
extra := map[string]any{
|
||||
"preferred_username": "john",
|
||||
}
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ func ConvertDERToPEM(der []byte, blockType PEMBlockType) ([]byte, error) {
|
|||
return buf.Bytes(), nil
|
||||
}
|
||||
|
||||
func publicKey(privateKey interface{}) interface{} {
|
||||
func publicKey(privateKey any) any {
|
||||
switch k := privateKey.(type) {
|
||||
case *rsa.PrivateKey:
|
||||
return &k.PublicKey
|
||||
|
@ -137,7 +137,7 @@ func publicKey(privateKey interface{}) interface{} {
|
|||
|
||||
// PrivateKeyBuilder interface for a private key builder.
|
||||
type PrivateKeyBuilder interface {
|
||||
Build() (interface{}, error)
|
||||
Build() (any, error)
|
||||
}
|
||||
|
||||
// RSAKeyBuilder builder of RSA private key.
|
||||
|
@ -152,7 +152,7 @@ func (rkb RSAKeyBuilder) WithKeySize(bits int) RSAKeyBuilder {
|
|||
}
|
||||
|
||||
// Build a RSA private key.
|
||||
func (rkb RSAKeyBuilder) Build() (interface{}, error) {
|
||||
func (rkb RSAKeyBuilder) Build() (any, error) {
|
||||
return rsa.GenerateKey(rand.Reader, rkb.keySizeInBits)
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ func (rkb RSAKeyBuilder) Build() (interface{}, error) {
|
|||
type Ed25519KeyBuilder struct{}
|
||||
|
||||
// Build an Ed25519 private key.
|
||||
func (ekb Ed25519KeyBuilder) Build() (interface{}, error) {
|
||||
func (ekb Ed25519KeyBuilder) Build() (any, error) {
|
||||
_, priv, err := ed25519.GenerateKey(rand.Reader)
|
||||
return priv, err
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ func (ekb ECDSAKeyBuilder) WithCurve(curve elliptic.Curve) ECDSAKeyBuilder {
|
|||
}
|
||||
|
||||
// Build an ECDSA private key.
|
||||
func (ekb ECDSAKeyBuilder) Build() (interface{}, error) {
|
||||
func (ekb ECDSAKeyBuilder) Build() (any, error) {
|
||||
return ecdsa.GenerateKey(ekb.curve, rand.Reader)
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ func ParseX509FromPEM(data []byte) (key any, err error) {
|
|||
}
|
||||
|
||||
// CastX509AsCertificate converts an interface to an *x509.Certificate.
|
||||
func CastX509AsCertificate(c interface{}) (certificate *x509.Certificate, ok bool) {
|
||||
func CastX509AsCertificate(c any) (certificate *x509.Certificate, ok bool) {
|
||||
switch t := c.(type) {
|
||||
case x509.Certificate:
|
||||
return &t, true
|
||||
|
@ -225,7 +225,7 @@ func CastX509AsCertificate(c interface{}) (certificate *x509.Certificate, ok boo
|
|||
}
|
||||
|
||||
// IsX509PrivateKey returns true if the provided interface is an rsa.PrivateKey, ecdsa.PrivateKey, or ed25519.PrivateKey.
|
||||
func IsX509PrivateKey(i interface{}) bool {
|
||||
func IsX509PrivateKey(i any) bool {
|
||||
switch i.(type) {
|
||||
case rsa.PrivateKey, *rsa.PrivateKey, ecdsa.PrivateKey, *ecdsa.PrivateKey, ed25519.PrivateKey, *ed25519.PrivateKey:
|
||||
return true
|
||||
|
@ -328,7 +328,7 @@ func WriteCertificateBytesToPEM(cert []byte, path string, csr bool) (err error)
|
|||
}
|
||||
|
||||
// WriteKeyToPEM writes a key that can be encoded as a PEM to a file in the PEM format.
|
||||
func WriteKeyToPEM(key interface{}, path string, pkcs8 bool) (err error) {
|
||||
func WriteKeyToPEM(key any, path string, pkcs8 bool) (err error) {
|
||||
pemBlock, err := PEMBlockFromX509Key(key, pkcs8)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -349,7 +349,7 @@ func WriteKeyToPEM(key interface{}, path string, pkcs8 bool) (err error) {
|
|||
}
|
||||
|
||||
// PEMBlockFromX509Key turns a PublicKey or PrivateKey into a pem.Block.
|
||||
func PEMBlockFromX509Key(key interface{}, pkcs8 bool) (pemBlock *pem.Block, err error) {
|
||||
func PEMBlockFromX509Key(key any, pkcs8 bool) (pemBlock *pem.Block, err error) {
|
||||
var (
|
||||
data []byte
|
||||
blockType string
|
||||
|
@ -491,7 +491,7 @@ func EllipticCurveFromString(curveString string) (curve elliptic.Curve) {
|
|||
}
|
||||
|
||||
// PublicKeyFromPrivateKey returns a PublicKey when provided with a PrivateKey.
|
||||
func PublicKeyFromPrivateKey(privateKey interface{}) (publicKey interface{}) {
|
||||
func PublicKeyFromPrivateKey(privateKey any) (publicKey any) {
|
||||
switch k := privateKey.(type) {
|
||||
case *rsa.PrivateKey:
|
||||
return &k.PublicKey
|
||||
|
|
Loading…
Reference in New Issue