Documentation
¶
Overview ¶
Package verify provides middleware for GRPc servers which need to verify JSON Web Tokens generated by this Authenticator service.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseJWTHeader ¶
ParseJWTHeader checks is the Alg field is supported and returns the Kid as an int.
Example ¶
package main
import (
"encoding/base64"
"fmt"
"log"
"github.com/moapis/authenticator/verify"
)
func main() {
token := base64.RawURLEncoding.EncodeToString([]byte("{\"Alg\": \"EdDSA\", \"Kid\": \"10\"}"))
kid, err := verify.ParseJWTHeader(token)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Key ID: %d", kid)
}
Output: Key ID: 10
Types ¶
type RetrieveError ¶
type RetrieveError struct {
VerificationErr
}
RetrieveError in case of gRPC client errors.
type VerificationErr ¶
type VerificationErr struct {
// contains filtered or unexported fields
}
VerificationErr type for errors generated by this package.
Example ¶
package main
import (
"encoding/base64"
"errors"
"fmt"
"github.com/moapis/authenticator/verify"
)
func main() {
token := base64.RawURLEncoding.EncodeToString([]byte("{\"Alg\": \"foo\"}"))
_, err := verify.ParseJWTHeader(token)
var ve *verify.VerificationErr
if errors.As(err, &ve) {
fmt.Printf("Error is of type %T", ve)
}
}
Output: Error is of type *verify.VerificationErr
func (*VerificationErr) Error ¶
func (e *VerificationErr) Error() string
func (*VerificationErr) Unwrap ¶
func (e *VerificationErr) Unwrap() error
Unwrap returns the originating error
type Verificator ¶
type Verificator struct {
Client pb.AuthenticatorClient
// contains filtered or unexported fields
}
Verificator holds public keys, which are used to verify tokens. Public keys that are not found in the local cache, are retrieved through an gRPC call from an Authenticator server.
Click to show internal directories.
Click to hide internal directories.