Categorygithub.com/wingfeng/idx-oauth2
modulepackage
0.12.2
Repository: https://github.com/wingfeng/idx-oauth2.git
Documentation: pkg.go.dev

# README

Golang OAuth 2.0 Server Implement IDX-OAUTH2

GitHub stars GitHub forks GitHub issues Go Reference ReportCard License

About

This project is for who want to build your own OAUTH2 and OIDC server with golang,It use for oauth2 to support OIDC and device code grant type. Build your own repository to store users and clients authorizations. the repository provided in this module is just a sample. and it is not recommended to use it in production.

Features

OAuth2.0 Server Implementation, Support Grant Types:

Quick Start

1. Download and Install go module

go get -u -v github.com/wingfeng/idx-oauth2

2. create your main function

you can find the example in ./example/mainInMem.go

import oauth2 "github.com/wingfeng/idx-oauth2"

func main() {

	config := conf.DefaultConfig()
	config.Scheme = "http"

	router := gin.Default()

	store := memstore.NewStore([]byte("secret"))

	sessionHandler := sessions.Sessions("mysession", store)
	router.LoadHTMLGlob("../static/*.html")
	router.Static("/img", "../static/img")
	tokenService, jwks := buildTokenService(config)
	clientRepo := buildClientRepo()
	authRepo := repo.NewInMemoryAuthorizeRepository()

	consentRepo := repo.NewInMemoryConsentRepository()

	userService := &service.DefaultUserService{
		UserRepository: buildUserRepo(),
	}
	tenant := oauth2.NewTenant(config, clientRepo, authRepo, consentRepo, userService, tokenService, jwks)

	tenant.InitOAuth2Router(router, sessionHandler)

	address := fmt.Sprintf("%s:%d", "", 9097)
	router.Run(address)
	}

3. test it with the example client

you can find the example client in ./example/client/main.go it is the sample client for oauth2 from https://github.com/go-oauth2/oauth2, open another terminal to run followed command

    cd ./example/client
    go run .

Open your browser with http://localhost:9000/

4. test it other ways

License

This project is licensed under the MIT License - see the LICENSE file for details.

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

No description provided by the author

# Structs

No description provided by the author