# README
go-oauth2-arangodb
This package is an ArangoDB storage implementation for go-oauth2 using ArangoDB's official go-driver.
The package is following semantic versioning and is not tied to the versioning of go-oauth2.
Installation
go get github.com/gabor-boros/go-oauth2-arangodb
Example usage
package main
import (
"context"
"os"
arangoDriver "github.com/arangodb/go-driver"
arangoHTTP "github.com/arangodb/go-driver/http"
"github.com/go-oauth2/oauth2/v4/manage"
arangoStore "github.com/gabor-boros/go-oauth2-arangodb"
)
func main() {
conn, _ := arangoHTTP.NewConnection(arangoHTTP.ConnectionConfig{
Endpoints: []string{os.Getenv("ARANGO_URL")},
})
client, _ := arangoDriver.NewClient(arangoDriver.ClientConfig{
Connection: conn,
Authentication: arangoDriver.BasicAuthentication(os.Getenv("ARANGO_USER"), os.Getenv("ARANGO_PASSWORD")),
})
db, _ := client.Database(context.Background(), os.Getenv("ARANGO_DB"))
clientStore, _ := arangoStore.NewClientStore(
arangoStore.WithClientStoreDatabase(db),
arangoStore.WithClientStoreCollection("oauth2_clients"),
)
tokenStore, _ := arangoStore.NewTokenStore(
arangoStore.WithTokenStoreDatabase(db),
arangoStore.WithTokenStoreCollection("oauth2_tokens"),
)
manager := manage.NewDefaultManager()
manager.MapTokenStorage(tokenStore)
manager.MapClientStorage(clientStore)
// ...
}
Contributing
Contributions are welcome! Please open an issue or a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
# Functions
NewClientStore creates a new ClientStore.
NewTokenStore creates a new TokenStore.
WithClientStoreCollection configures the collection for the ClientStore.
WithClientStoreDatabase configures the database for the ClientStore.
WithTokenStoreCollection configures the collection for the TokenStore.
WithTokenStoreDatabase configures the database for the TokenStore.
# Constants
DefaultClientStoreCollection is the default collection for storing clients.
nolint: gosec.
# Variables
ErrNoCollection is returned when no collection is provided.
ErrNoDatabase is returned when no database is provided.
# Structs
ClientStore is a data struct that stores oauth2 client information.
ClientStoreItem data item.
TokenStore is a data struct that stores oauth2 client information.
TokenStoreItem data item.
# Type aliases
ClientStoreOption is a function that configures the ClientStore.
TokenStoreOption is a function that configures the TokenStore.