add authentication endpoints and Redis integration
This commit is contained in:
28
internal/hydra_client/hydra_client.go
Normal file
28
internal/hydra_client/hydra_client.go
Normal file
@ -0,0 +1,28 @@
|
||||
package hydra_client
|
||||
|
||||
import (
|
||||
"git.logidex.ru/fakz9/logidex-id/internal/config"
|
||||
hydraApi "github.com/ory/hydra-client-go"
|
||||
"sync"
|
||||
)
|
||||
|
||||
var (
|
||||
client *hydraApi.APIClient
|
||||
initClient sync.Once
|
||||
)
|
||||
|
||||
func InitClient() {
|
||||
cfg := hydraApi.NewConfiguration()
|
||||
cfg.AddDefaultHeader("X-Secret", config.Cfg.Hydra.Password)
|
||||
cfg.Servers = []hydraApi.ServerConfiguration{
|
||||
{
|
||||
URL: config.Cfg.Hydra.Host,
|
||||
},
|
||||
}
|
||||
client = hydraApi.NewAPIClient(cfg)
|
||||
}
|
||||
|
||||
func GetClient() *hydraApi.APIClient {
|
||||
initClient.Do(InitClient)
|
||||
return client
|
||||
}
|
||||
Reference in New Issue
Block a user