Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IClaimsValidator ¶
IClaimsValidator 這是為了讓使用者可以自定義特殊欄位的驗證
type MyCustomClaims struct { jwt.RegisteredClaims // 這個包含標準的方法,你就不需要再自定義 Foo string `json:"foo"` } func (m MyCustomClaims) Validate() error { // 自定義你的驗證邏輯 if m.Foo != "bar" { return errors.New("must be foobar") } return nil }
type Validator ¶
type Validator struct { // timeFunc 驗證用的時間其基準,預設使用 time.Now() TimeFunc func() time.Time //require的項目表示,如果claims沒有提到此key,那麼是否要報錯 RequireIssuer bool // iss RequireSubject bool // sub RequireAudience bool // aud RequireExpirationTime bool // exp RequireNotBefore bool // nbf RequireIssueAt bool // iat // verify的項目,表示是否做該驗證 VerifyIat bool ExpectedIssuer string ExpectedSubject string ExpectedAudience string }
Click to show internal directories.
Click to hide internal directories.