@@ -50,7 +50,7 @@ var defaultConfig = Config{
5050 },
5151 Signing : signingConfs {
5252 Mytoken : signingConf {
53- Alg : SignatureAlgorithm { SignatureAlgorithm : jwa . ES512 ()} ,
53+ Alg : " ES512" ,
5454 RSAKeyLen : 2048 ,
5555 },
5656 OIDC : oidcSigningConf {
@@ -126,7 +126,7 @@ var defaultConfig = Config{
126126 Enabled : false ,
127127 EntityConfigurationLifetime : 7 * 24 * 60 * 60 ,
128128 Signing : signingConf {
129- Alg : SignatureAlgorithm { SignatureAlgorithm : jwa . ES512 ()} ,
129+ Alg : " ES512" ,
130130 RSAKeyLen : 2048 ,
131131 },
132132 OPDiscovery : opDiscoveryConf {
@@ -453,33 +453,9 @@ type signingConfs struct {
453453}
454454
455455type signingConf struct {
456- Alg SignatureAlgorithm `yaml:"alg"`
457- KeyFile string `yaml:"key_file"`
458- RSAKeyLen int `yaml:"rsa_key_len"`
459- }
460-
461- // SignatureAlgorithm is a jwa.SignatureAlgorithm that can be marshalled to and unmarshalled from YAML.
462- type SignatureAlgorithm struct {
463- jwa.SignatureAlgorithm
464- }
465-
466- // UnmarshalYAML implements yaml.Unmarshaler for SignatureAlgorithm.
467- func (a * SignatureAlgorithm ) UnmarshalYAML (value * yaml.Node ) error {
468- var s string
469- if err := value .Decode (& s ); err != nil {
470- return errors .Wrap (err , "invalid signing algorithm" )
471- }
472- alg , ok := jwa .LookupSignatureAlgorithm (s )
473- if ! ok {
474- return errors .Errorf ("unknown signing algorithm '%s'" , s )
475- }
476- a .SignatureAlgorithm = alg
477- return nil
478- }
479-
480- // MarshalYAML implements yaml.Marshaler for SignatureAlgorithm.
481- func (a SignatureAlgorithm ) MarshalYAML () (interface {}, error ) {
482- return a .String (), nil
456+ Alg string `yaml:"alg"`
457+ KeyFile string `yaml:"key_file"`
458+ RSAKeyLen int `yaml:"rsa_key_len"`
483459}
484460
485461// oidcSigningConf holds configuration for OIDC signing with multiple algorithms
@@ -653,9 +629,12 @@ func (f *federationConf) validate() (err error) {
653629 if f .Signing .KeyFile == "" {
654630 return errors .New ("federation enabled, but no signing keyfile specified" )
655631 }
656- if f .Signing .Alg . String () == "" {
632+ if f .Signing .Alg == "" {
657633 return errors .New ("federation enabled, but no signing alg specified" )
658634 }
635+ if _ , ok := jwa .LookupSignatureAlgorithm (f .Signing .Alg ); ! ok {
636+ return errors .Errorf ("federation enabled, but unknown signing alg '%s' specified" , f .Signing .Alg )
637+ }
659638 if f .EntityConfigurationLifetime == 0 {
660639 f .EntityConfigurationLifetime = 7 * 24 * 60 * 60
661640 }
@@ -819,9 +798,12 @@ func validateSigningConfig() error {
819798 if conf .Signing .Mytoken .KeyFile == "" {
820799 return errors .New ("invalid config: signing keyfile not set" )
821800 }
822- if conf .Signing .Mytoken .Alg . String () == "" {
801+ if conf .Signing .Mytoken .Alg == "" {
823802 return errors .New ("invalid config: token signing alg not set" )
824803 }
804+ if _ , ok := jwa .LookupSignatureAlgorithm (conf .Signing .Mytoken .Alg ); ! ok {
805+ return errors .Errorf ("invalid config: unknown token signing alg '%s'" , conf .Signing .Mytoken .Alg )
806+ }
825807 return nil
826808}
827809
0 commit comments