// NewTokenManager returns a token mapper that performs bearer token authorization.
NewTokenManager returns a token mapper that performs bearer token authorization.
// NewTokenManager returns a token mapper that performs bearer token authorization .
func NewTokenManager(cfg Config) (*TokenManager, error) {
	defs := make([]*tokenDef, len(cfg.AuthTokensDef))
	for i, def := range cfg.AuthTokensDef {
		expr, err := regexp.Compile(def.EndpointExpression)
		if err != nil {
			return nil, fmt.Errorf("invalid endpoint expression [%s]: %w", def.EndpointExpression, err)
		}
		defs[i] = &tokenDef{
			expr:        expr,
			readTokens:  def.ReadTokens,
			writeTokens: def.WriteTokens,
		}
	}
	return &TokenManager{
		tokenDefs:  defs,
		authTokens: cfg.AuthTokens,
	}, nil
}
func NewTokenManager ( cfg Config ) ( * TokenManager , error ) { defs := make ( [ ] * tokenDef , len ( cfg . AuthTokensDef ) ) for i , def := range cfg . AuthTokensDef { expr , err := regexp . Compile ( def . EndpointExpression ) if err != nil { return nil , fmt . Errorf ( " " , def . EndpointExpression , err ) } defs [ i ] = & tokenDef { expr : expr , readTokens : def . ReadTokens , writeTokens : def . WriteTokens , } } return & TokenManager { tokenDefs : defs , authTokens : cfg . AuthTokens , } , nil }
NewTokenManager returns a token mapper that performs bearer token authorization.
NewTokenManager returns a token mapper that performs bearer token authorization .