ory / kratos

The most scalable and customizable identity server on the market. Replace your Homegrown, Auth0, Okta, Firebase with better UX and DX. Has all the tablestakes: Passkeys, Social Sign In, Multi-Factor Auth, SMS, SAML, TOTP, and more. Written in Go, cloud native, headless, API-first. Available as a service on Ory Network and for self-hosters.
https://www.ory.sh/?utm_source=github&utm_medium=banner&utm_campaign=kratos
Apache License 2.0
11.24k stars 963 forks source link

I want to generate the totp key with Kratos Identities in my application ,what should I do?Is theres any API or Url for this in Kratos #2509

Closed Answerlord closed 2 years ago

Answerlord commented 2 years ago

Preflight checklist

Describe your problem

I'd like to design a RESTful API for my application to generate the totp key,like the kratos-selfservice-ui-node,so that I can accomplish the MFA. I have found the function for generating the totp key in the code of Kratos:

func NewKey(ctx context.Context, accountName string, d interface {
    config.Provider
}) (*otp.Key, error) {
                ...
        return key, err
}

But I don't know how to use it (I don't know how to initialize the arguments that calls d),and the code of Kratos only provide the example for testing.I have no idea for using it in my code.

Describe your ideal solution

Is there an API or Url for generating the totp key in Kratos client? Or would u mind to provide this feature in your SDKs.

Workarounds or alternatives

I have no idea now.Maybe I can learn REACT to figure out how it works in kratos-selfservice-ui-node,and use its way to accomplish the generation of totp key

Version

v0.9.0-alpha.2

Additional Context

No response

aeneasr commented 2 years ago

Use: https://github.com/pquerna/otp