Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation update for 1.8.0 #6

Open
coin-au-carre opened this issue Mar 7, 2024 · 1 comment
Open

Documentation update for 1.8.0 #6

coin-au-carre opened this issue Mar 7, 2024 · 1 comment

Comments

@coin-au-carre
Copy link

coin-au-carre commented Mar 7, 2024

The following line is not working anymore in https://www.ory.sh/docs/getting-started/integrate-auth/go#create-http-server with 1.8.0

// dashboard
mux.Handle("/", app.sessionMiddleware(app.dashboardHandler()))

I am using Go 1.22

@coin-au-carre
Copy link
Author

coin-au-carre commented Mar 7, 2024

https://www.ory.sh/docs/kratos/sdk/go is also incorrect.
I propose this

package web

import (
	"context"
	"fmt"
	"os"

	"github.com/ory/client-go"
)

type oryMiddleware struct {
	*client.APIClient
}

func NewOryMiddleware() *oryMiddleware {
	cfg := client.NewConfiguration()
	cfg.Servers = client.ServerConfigurations{
		{URL: fmt.Sprintf("https://%s.projects.oryapis.com", os.Getenv("ORY_PROJECT_SLUG"))},
	}

	return &oryMiddleware{client.NewAPIClient(cfg)}
}

func NewOryMiddleware() *oryMiddleware {
	cfg := client.NewConfiguration()
	cfg.Servers = client.ServerConfigurations{
		{URL: fmt.Sprintf("https://%s.projects.oryapis.com", os.Getenv("ORY_PROJECT_SLUG"))},
	}

	return &oryMiddleware{client.NewAPIClient(cfg)}
}

func createLogin(ctx context.Context, ory *oryMiddleware) (*client.LoginFlow, error) {
	flow, _, err := ory.FrontendAPI.CreateBrowserLoginFlow(ctx).Execute()
	if err != nil {
		return nil, err
	}

	return flow, nil
}

func createRegistration(ctx context.Context, ory *oryMiddleware) (*client.RegistrationFlow, error) {
	flow, _, err := ory.FrontendAPI.CreateNativeRegistrationFlow(ctx).Execute()
	if err != nil {
		return nil, err
	}

	return flow, nil
}

func CreateRecovery(ctx context.Context, ory *oryMiddleware) (*client.RecoveryFlow, error) {
	flow, _, err := ory.FrontendAPI.CreateNativeRecoveryFlow(ctx).Execute()
	if err != nil {
		return nil, err
	}

	return flow, nil
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant