Oauth2
Interface oriented implementation, no coupling with the model and database, support for GC
Install / Use
/learn @SagaciousHugo/Oauth2README
Golang Oauth2 Server
Based on the secondary development github.com/go-oauth2, provides TokenStore and TokenGenerator based on interface can be pull out plug type design, can easily customize their need TokenStore and the Generator, and support the TokenGC.
Features
- clear configuration items with default configuration(config.go)
- 7 custom hooks are supported to extend logic in the authorization process (server/handler.go)
- support response in hook functions (such as output authorization page, error page, etc., subsequent authorization logic is automatically interrupted)
- support for Token GC
- support custom Token Store with any database (you need to implement the store.tokenstore interface yourself)
- support custom Token Generator with any algorithm (you need to implement the Generator.Generator interface yourself)
- based entirely on RFC 6749 implementation (support RedirectURI is empty, support multiple RedirectURI configuration)
Quick Start
Download and install
go get github.com/sagacioushugo/oauth2
Build and run example
go build server.go
./server
go build client.go
./client
Request to client in browser
After receiving the corresponding request, the client will automatically simulate a certain authorization pattern and return the token obtained to the browser
Test the authorization process with RFC 6749 and client logs
Authorization Pattern| Client Url | note ---|---|--- Authorization Code|http://localhost:8080/test/authorization_code | Implicit|http://localhost:8080/test/implicit | Password Credentials|http://localhost:8080/test/password| Client Credentials | http://localhost:8080/test/client_credentials| Refreshing an access token|http://localhost:8080/test/refresh_token?refresh_token=yourtoken| param refresh_token is required
Documentation
Apache License 2.0
Copyright (c) 2019 Guoyiming
Related Skills
feishu-drive
344.4k|
things-mac
344.4kManage Things 3 via the `things` CLI on macOS (add/update projects+todos via URL scheme; read/search/list from the local Things database)
clawhub
344.4kUse the ClawHub CLI to search, install, update, and publish agent skills from clawhub.com
postkit
PostgreSQL-native identity, configuration, metering, and job queues. SQL functions that work with any language or driver
