Documentation

Index

Constants

View Source
const NoExpiration int64 = 0

    NoExpiration can be passed to the generator to indicate no expiration time.

    Variables

    This section is empty.

    Functions

    This section is empty.

    Types

    type Clock

    type Clock interface {
    	// Now tells the current time.
    	Now() time.Time
    }

      Clock provides an interface to Time.

      type IDGenerator

      type IDGenerator interface {
      	Generate() string
      }

        IDGenerator generates an opaque ID.

        type JWTTokenGenerator

        type JWTTokenGenerator struct {
        	// contains filtered or unexported fields
        }

          JWTTokenGenerator generates an API token.

          func NewJWTTokenGenerator

          func NewJWTTokenGenerator(issuer string, audience string, signingKey string, opts ...JWTTokenGeneratorOption) JWTTokenGenerator

            NewJWTTokenGenerator returns a new JWTTokenGenerator.

            func (JWTTokenGenerator) GenerateToken

            func (g JWTTokenGenerator) GenerateToken(sub string, expiresAt int64, tokenType string, tokenText string) (string, string, error)

              GenerateToken generates a JWT token.

              type JWTTokenGeneratorOption

              type JWTTokenGeneratorOption interface {
              	// contains filtered or unexported methods
              }

                JWTTokenGeneratorOption option configures optional parameters of a JWTTokenGenerator.

                func TokenGeneratorClock

                func TokenGeneratorClock(clock Clock) JWTTokenGeneratorOption

                  TokenGeneratorClock sets the clock in a JWTTokenGenerator. It falls back to the system clock.

                  func TokenIDGenerator

                  func TokenIDGenerator(idgen IDGenerator) JWTTokenGeneratorOption

                    TokenIDGenerator sets the ID Generator in a JWTTokenGenerator. It falls back to UUID.

                    func TokenSigningMethod

                    func TokenSigningMethod(signingMethod jwt.SigningMethod) JWTTokenGeneratorOption

                      TokenSigningMethod sets the signing method in a JWTTokenGenerator. It falls back to jwt.SigningMethodHS256.

                      type TokenGenerator

                      type TokenGenerator interface {
                      	// GenerateToken generates a token.
                      	GenerateToken(sub string, expiresAt int64, tokenType string, tokenText string) (string, string, error)
                      }

                        TokenGenerator generates a token.

                        type TokenManager

                        type TokenManager struct {
                        	// contains filtered or unexported fields
                        }

                          TokenManager manages tokens.

                          func NewTokenManager

                          func NewTokenManager(generator TokenGenerator, store auth.TokenStore) TokenManager

                            NewTokenManager returns a new TokenManager.

                            func (TokenManager) GenerateToken

                            func (m TokenManager) GenerateToken(
                            	sub string,
                            	expiresAt *time.Time,
                            	tokenType TokenType,
                            	tokenText string,
                            	tokenName string,
                            	storeSecret bool,
                            ) (string, string, error)

                              GenerateToken generates a token and stores it in the token store.

                              type TokenType

                              type TokenType string

                                TokenType represents one of the possible token Types.

                                Source Files