...

Source file src/github.com/MicahParks/keyfunc/v2/examples/custom/method/method.go

Documentation: github.com/MicahParks/keyfunc/v2/examples/custom/method

     1  package method
     2  
     3  // CustomAlgHeader is the `alg` JSON attribute's value for the example custom jwt.SigningMethod.
     4  const CustomAlgHeader = "customalg"
     5  
     6  // EmptyCustom implements the jwt.SigningMethod interface. It will not sign or verify anything.
     7  type EmptyCustom struct{}
     8  
     9  // Verify helps implement the jwt.SigningMethod interface. It does not verify.
    10  func (e EmptyCustom) Verify(_ string, _ []byte, _ interface{}) error {
    11  	return nil
    12  }
    13  
    14  // Sign helps implement the jwt.SigningMethod interface. It does not sign anything.
    15  func (e EmptyCustom) Sign(_ string, _ interface{}) ([]byte, error) {
    16  	return []byte{}, nil
    17  }
    18  
    19  // Alg helps implement the jwt.SigningMethod. It returns the `alg` JSON attribute for JWTs signed with this method.
    20  func (e EmptyCustom) Alg() string {
    21  	return CustomAlgHeader
    22  }
    23  

View as plain text