mirror of
https://github.com/davidallendj/opaal.git
synced 2025-12-20 03:27:02 -07:00
Refactor and added ability to use include multiple providers in config
This commit is contained in:
parent
53d1a8cc35
commit
4bca62ec2f
13 changed files with 660 additions and 712 deletions
32
internal/identities.go
Normal file
32
internal/identities.go
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
package opaal
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/davidallendj/go-utils/httpx"
|
||||
)
|
||||
|
||||
func (client *Client) CreateIdentity(url string, idToken string) error {
|
||||
// kratos endpoint: /admin/identities
|
||||
body := []byte(`{
|
||||
"schema_id": "preset://email",
|
||||
"traits": {
|
||||
"email": "docs@example.org"
|
||||
}
|
||||
}`)
|
||||
headers := httpx.Headers{
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": fmt.Sprintf("Bearer %s", idToken),
|
||||
}
|
||||
_, _, err := httpx.MakeHttpRequest(url, http.MethodPost, body, headers)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to read response body: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (client *Client) FetchIdentities(remoteUrl string) ([]byte, error) {
|
||||
_, b, err := httpx.MakeHttpRequest(remoteUrl, http.MethodGet, []byte{}, httpx.Headers{})
|
||||
return b, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue