https://github.com/alextanhongpin/go-openid
Creating an openid with golang
https://github.com/alextanhongpin/go-openid
api golang openid rest-api
Last synced: about 1 year ago
JSON representation
Creating an openid with golang
- Host: GitHub
- URL: https://github.com/alextanhongpin/go-openid
- Owner: alextanhongpin
- Created: 2017-05-24T17:17:06.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-05-27T17:07:02.000Z (about 7 years ago)
- Last Synced: 2025-03-24T16:29:37.998Z (over 1 year ago)
- Topics: api, golang, openid, rest-api
- Language: Go
- Size: 5.14 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-openid
Creating an OpenID Connect with golang. Things I've learn throughout the process.
- how to setup enum
- bitwise operator for conditionals
## Wiring Dependencies
Using `wire`.
```go
func ProvideRepository() *database.ClientKV {
return database.NewClientKV()
}
func ProvideModel(r repository.Client, v map[string]schema.Validator) *clientModelImpl {
return NewClientModelImpl(r, v)
}
func ProvideService(m model.Client) *clientServiceImpl {
return NewClientServiceImpl(m)
}
var ClientMegaSet = wire.NewSet(
ProvideRepository,
wire.Bind(new(repository.Client), new(database.ClientKV)),
ProvideModel,
wire.Bind(new(model.Client), new(clientModelImpl)),
ProvideService)
var ClientSet = wire.NewSet(
// Creates a new pointer to the struct *ClientKV.
database.NewClientKV,
// Map the struct *ClientKV to the interface repository.Client to be
// used as the next argument.
wire.Bind(new(repository.Client), new(database.ClientKV)),
// Accepts the previous repository.Client interface, but skip the
// second argument. The second argument will be required as a
// parameter, since we do not defined it here. Returns a pointer to the
// struct *clientModelImpl.
NewClientModelImpl,
// Take the previous struct pointer and convert it to the interface
// type.
wire.Bind(new(model.Client), new(clientModelImpl)),
// Takes the previous interface and returns a pointer to the
// *clientServiceImpl.
NewClientServiceImpl)
```
Both produces the same result:
```go
// Code generated by Wire. DO NOT EDIT.
//go:generate wire
//+build !wireinject
package client
import (
database "github.com/alextanhongpin/go-openid/internal/database"
schema "github.com/alextanhongpin/go-openid/pkg/schema"
)
// Injectors from wire.go:
func NewService(arg map[string]schema.Validator) *clientServiceImpl {
clientKV := database.NewClientKV()
clientClientModelImpl := NewClientModelImpl(clientKV, arg)
clientClientServiceImpl := NewClientServiceImpl(clientClientModelImpl)
return clientClientServiceImpl
}
func NewSimplerService(arg map[string]schema.Validator) *clientServiceImpl {
clientKV := ProvideRepository()
clientClientModelImpl := ProvideModel(clientKV, arg)
clientClientServiceImpl := ProvideService(clientClientModelImpl)
return clientClientServiceImpl
}
```
## TODOS
- add check login multiple time (and captcha)
- add block ip functionality