Skip to content

Validate multiple subjects #408

Open
@miparnisari

Description

@miparnisari

jwt/parser_option.go

Lines 97 to 105 in 5ec246c

// WithSubject configures the validator to require the specified subject in the
// `sub` claim. Validation will fail if a different subject is specified in the
// token or the `sub` claim is missing.
//
// NOTE: While the `sub` claim is OPTIONAL in a JWT, the handling of it is
// application-specific. Since this validation API is helping developers in
// writing secure application, we decided to REQUIRE the existence of the claim,
// if a subject is expected.
func WithSubject(sub string) ParserOption {

Would it be possible to add a convenience validator method jwt.WithSubjects(subjects []string) that returns an error if the request's subject doesn't match any of the subjects?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions