{"modulePath":"github.com/BeanCodeDe/authi","version":"v1.2.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package parser\n\nPackage to verify tokens\n\n## Constants\n\n```go\nconst (\n\t// Environment variable to point to path of the public key file\n\tEnvPublicKeyPath = \"PUBLIC_KEY_PATH\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\t// Token could not be recognized in authorizationString\n\tErrTokenNotFound = errors.New(\"token not found\")\n\t// Claim doesn't match content from token\n\tErrClaimCouldNotBeParsed = errors.New(\"claim could not be parsed\")\n\t// Token is not valid. Maybe it is expired or doesn't match the public key\n\tErrTokenNotValid = errors.New(\"token is not valid\")\n\t// Public key from environment variable PUBLIC_KEY_PATH couldn't be read\n\tErrWhileReadingKey = errors.New(\"error while reading public key\")\n\t// Public key seams to not have the valid format\n\tErrWhileParsingKey = errors.New(\"error while parsing public key\")\n)\n```\n\n## Types\n\n```go\ntype JWTParser struct {\n\t// contains filtered or unexported fields\n}\n```\nStruct to parse and validate jwt tokens\n\n```go\nfunc (parser *JWTParser) ParseToken(authorizationString string) (*adapter.Claims, error)\n```\nChecks if the bearer token is valid and returns its content as a claim\n\n```go\ntype ParseTokenRecord struct {\n\tAuthorizationString string\n}\n```\n\n```go\ntype ParseTokenResponse struct {\n\tClaim *adapter.Claims\n\tErr   error\n}\n```\n\n```go\ntype Parser interface {\n\tParseToken(authorizationString string) (*adapter.Claims, error)\n}\n```\nInterface fo pars and validate tokens\n\n```go\nfunc NewJWTParser() (Parser, error)\n```\nConstructor to create jwt parser. public key path have to be set under environment variable PUBLIC\\_KEY\\_PATH\n\n```go\ntype ParserMock struct {\n\tParseTokenRecordArray   []*ParseTokenRecord\n\tParseTokenResponseArray []*ParseTokenResponse\n}\n```\n\n```go\nfunc (mock *ParserMock) ParseToken(authorizationString string) (*adapter.Claims, error)\n```\n\n","path":"github.com/BeanCodeDe/authi/pkg/parser","name":"parser","synopsis":"Package to verify tokens","isRedistributable":true}
