Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/liut/osin-storage

A storage backend for osin oauth2
https://github.com/liut/osin-storage

oauth2 osin osin-oauth2 osin-storage postgres

Last synced: 1 day ago
JSON representation

A storage backend for osin oauth2

Awesome Lists containing this project

README

        

# osin-storage
A storage backend for [osin oauth2](https://github.com/openshift/osin) with:

* `storage/pg`: [go-pg](https://github.com/go-pg/pg).
* `storage/sqlstore`: [pq](https://github.com/lib/pq) or [sqlx](https://github.com/jmoiron/sqlx)

This project was inspired from [ory-am](https://github.com/ory-am/osin-storage)

## Addition features

* Save map and struct meta information with `JSON`(or `JSONB`) for Client and Authorization
* Use `SaveClient()` instead of `CreateClient()` and `UpdateClient()`
* Add `AllClients() []` interface for management
* Add remember function for authorization

## Prepare database

```sh
cat storage/database/oauth_schema.sql | docker exec -i osin-db psql -U osin
```

## Example

```go

import (
"database/sql"

_ "github.com/lib/pq"
"github.com/liut/osin-storage/storage/sqlstore"
"github.com/openshift/osin"
)

func main () {
dsn := "postgres://osin:[email protected]:5432/osin?sslmode=disable"
db, err := sql.Open("postgres", dsn)
if err != nil {
log.Fatal(err)
}

store := sqlstore.New(db)
server := osin.NewServer(newOsinConfig(), store)
}

```