Categorygithub.com/clowre/go-oauth2-hazelcast
modulepackage
1.0.2
Repository: https://github.com/clowre/go-oauth2-hazelcast.git
Documentation: pkg.go.dev

# README

Hazelcast store for go-oauth2/oauth2

CircleCI codecov

The store requires a runnig *hazelcast.Client to manage tokens and codes.

package main 

import (
    "context"

    "github.com/go-oauth2/oauth2/v4"
    "github.com/go-oauth2/oauth2/v4/models"
    "github.com/hazelcast/hazelcast-go-client"

    "github.com/clowre/go-oauth2-hazelcast"
)

func main() {
    
    ctx := context.Background()
    client, err := hazelcast.StartNewClient(ctx)
    if err != nil {
        panic(err)
    }
    defer client.Shutdown()

    store, err := hcstore.NewTokenStore(
        client,
        hcstore.WithAccessMapName("access_tokens"),
        hcstore.WithRefreshMapName("refresh_tokens"),
        hcstore.WithCodesMapName("codes"),
    )
    if err != nil {
        panic(err)
    }
}

The tests for this package assumes that there is a Hazelcast cluster running on localhost:5701.

# Functions

NewTokenStore creates an instances of `oauth2.TokenStore` connected to a Hazelcast cluster.
WithAccessMapName sets the name of the map that is used to save access tokens.
WithCodesMapName sets the name of the map that is used to save codes.
WithRefreshMapName sets the name of the map that is used to save refresh tokens.

# Type aliases

TokenStoreOption is a function that can be used to modify behavior of the `tokenStore`.