mirror of
https://github.com/paralus/paralus.git
synced 2026-08-22 12:56:31 +00:00
* created new migrations for null values Signed-off-by: zyncc <chandankrishna288@gmail.com> * fixed not null constraint for sentry_bootstrap_infra Signed-off-by: zyncc <chandankrishna288@gmail.com> * migrations not being applied Signed-off-by: zyncc <chandankrishna288@gmail.com> * added default values to all not null columns Signed-off-by: zyncc <chandankrishna288@gmail.com> * changes to kratos client api Signed-off-by: zyncc <chandankrishna288@gmail.com> * fixed casbin entries not showing in database Signed-off-by: zyncc <chandankrishna288@gmail.com> * . Signed-off-by: zyncc <chandankrishna288@gmail.com> * fixed create / upsert mismatch Signed-off-by: zyncc <chandankrishna288@gmail.com> * . Signed-off-by: zyncc <chandankrishna288@gmail.com> * . Signed-off-by: zyncc <chandankrishna288@gmail.com> * . Signed-off-by: zyncc <chandankrishna288@gmail.com> * . Signed-off-by: zyncc <chandankrishna288@gmail.com> * created one sql migration file Signed-off-by: zyncc <chandankrishna288@gmail.com> * . Signed-off-by: zyncc <chandankrishna288@gmail.com> * fixed CVE Vulnerability for golang and golang.org/x/oauth2 Signed-off-by: zyncc <chandankrishna288@gmail.com> * changed go version to 1.25.5 Signed-off-by: zyncc <chandankrishna288@gmail.com> * updated golangct-lint version to v2.6 Signed-off-by: zyncc <chandankrishna288@gmail.com> * golang-ci version Signed-off-by: zyncc <chandankrishna288@gmail.com> * added version to golang-ci.yaml Signed-off-by: zyncc <chandankrishna288@gmail.com> * fixed golangci config Signed-off-by: zyncc <chandankrishna288@gmail.com> --------- Signed-off-by: zyncc <chandankrishna288@gmail.com>
67 lines
1.7 KiB
Go
67 lines
1.7 KiB
Go
package pkg
|
|
|
|
import (
|
|
"context"
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/google/uuid"
|
|
|
|
ory "github.com/ory/kratos-client-go"
|
|
)
|
|
|
|
func RandomCredentials() (email, password string) {
|
|
email = "dev+" + uuid.New().String() + "@ory.sh"
|
|
password = strings.ReplaceAll(uuid.New().String(), "-", "")
|
|
return
|
|
}
|
|
|
|
// CreateIdentityWithSession creates an identity and an Ory Session Token for it.
|
|
func CreateIdentityWithSession(c *ory.APIClient, email, password string) (*ory.Session, string) {
|
|
ctx := context.Background()
|
|
|
|
if email == "" {
|
|
email, _ = RandomCredentials()
|
|
}
|
|
|
|
if password == "" {
|
|
_, password = RandomCredentials()
|
|
}
|
|
|
|
// Initialize a registration flow
|
|
flow, _, err := c.FrontendAPI.CreateNativeRegistrationFlow(ctx).Execute()
|
|
|
|
result, res, err := c.FrontendAPI.UpdateRegistrationFlow(ctx).Flow(flow.Id).UpdateRegistrationFlowBody(
|
|
ory.UpdateRegistrationFlowWithPasswordMethodAsUpdateRegistrationFlowBody(
|
|
&ory.UpdateRegistrationFlowWithPasswordMethod{
|
|
Method: "password",
|
|
Password: password,
|
|
Traits: map[string]interface{}{
|
|
"email": email,
|
|
"first_name": "Jon",
|
|
"last_name": "Doe",
|
|
"description": "nothing",
|
|
},
|
|
},
|
|
),
|
|
).Execute()
|
|
SDKExitOnError(err, res)
|
|
|
|
if result.Session == nil {
|
|
log.Fatalf("The server is expected to create sessions for new registrations.")
|
|
}
|
|
|
|
return result.Session, *result.SessionToken
|
|
}
|
|
|
|
func CreateIdentity(c *ory.APIClient) *ory.Identity {
|
|
ctx := context.Background()
|
|
|
|
email, _ := RandomCredentials()
|
|
|
|
identity, _, err := c.IdentityAPI.CreateIdentity(ctx).CreateIdentityBody(*ory.NewCreateIdentityBody("default", map[string]interface{}{"email": email,}})).Execute()
|
|
ExitOnError(err)
|
|
|
|
return identity
|
|
}
|