Skip to content

jwt.TimeFunc override: thread-safety #463

@imyixiao

Description

@imyixiao

this is more like a question instead of an issue:

  • context: we want to override jwt.TimeFunc to always read now from request header
func ApplyOverrideJWTTimeFunc(header http.Header) {
       jwt.TimeFunc = OverrideJWTTimeFunc(header)
}

func OverrideJWTTimeFunc(header http.Header) func() time.Time {
	return func() time.Time {
		return time.Unix(GetRequestTime(header), 0)
	}
}

// this func read time from request.header
func GetRequestTime(header http.Header)
  • concern: because this override jwt globally, will it be thread-safe or any unexpected risk when we deploy to production

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions