<@U03HLFCQ3CN> For one of our workflows we need to...
# ory-network
l
@fast-lunch-54279 For one of our workflows we need to automate patching some of the identity-config in CI (to enable redirect urls on ephemeral environments that we create on each PR). I’ve created an API key in the console to do this, and this works to allow me to use the identity APIs. However I can’t for the life of me get this to work with the project management API (specifically to patch the project configuration). Is there a separate way of authenticating against this API and what is your recommended flow to do this in a CI environment?
l
I think you need the ory session cookie unfortunately.
l
Urgh not ideal - the ory CLI does seem to work with this I guess I’ll look at the source of what it’s doing and see if I can replicate what it’s doing
Thanks for the help!
👍 1
Looks like there is a way forward using a console username & password to get a session token. This apes what the CLI is doing
Copy code
const getOrySessionToken = async (): Promise<string> => {
    const frontendApi = new ory.FrontendApi(
        new ory.Configuration({
            basePath: "<https://project.console.ory.sh>",
        })
    )

    const { ORY_USER_NAME, ORY_PASSWORD } = process.env
    if (!ORY_USER_NAME || !ORY_PASSWORD) {
        throw new Error("ORY_USER_NAME or ORY_PASSWORD are not defined")
    }
    const loginResult = await frontendApi.createNativeLoginFlow().then(
        flow => frontendApi.updateLoginFlow({
                flow: flow.data.id,
                updateLoginFlowBody: {
                    identifier: ORY_USER_NAME,
                    password: ORY_PASSWORD,
                    method: 'password',
                }
            })
    )
    return loginResult.data.session_token as string
}
f
@magnificent-energy-493 is about to publish a guide on GitOps via Ory CLI and Github Actios, I believe that’ll be helpful. generally cli is the recommend approach here
l
Ooooh that sounds interesting
Thanks - although I’m not sure if what I want can be exactly expressed through the CLI just yet
There is no way of expressing “I want this allowed_return_url” to exist with it. And the converse “I don’t want this allowed_return_url” to exist on a project
(or at least not with multiple calls to the CLI wrapped in a script - which is much more difficult to test than an approach using something like pulumi)
Do you have any plans on working with managing ory with something like terraform / pulumi?
f
@magnificent-energy-493 knows more about terraform, maybe he can comment on this
if you only use the CLI to fetch and push config, could you do your magic with return_urls just by parsing the config file maybe?
m
Yes there are plans to offer a Terraform Provider down the line. Nothing concrete as of yet though. There is a terraform provider for Ory Hydra, but not sure if that is usable for Ory Network