<@U04UQ68083H> Hey, I am new to ORY and Hydra. I ...
# ory-copilot
i
@chilly-king-10285 Hey, I am new to ORY and Hydra. I have a POC that I am looking to implement and after reading some of the docs some aspects are still not clear to me: • Can ORY connect to an SQL DB that already has a table that has users
email
and
passwords
are saved into, and use that as the IDP? ◦ Or do I have to import all of those users into ORY ? The main action I want to achieve is OpenID Connect - as a service.
c
A message from kapa.ai
Hello, Ory Hydra, which is a part of the Ory ecosystem, is designed to work with your existing identity management system. It doesn't contain a database with end users but instead uses HTTP redirection to delegate the login flow to another app. This means you can use your existing SQL database that already has a table with users'
email
and
passwords
saved into it. You don't have to import all of those users into Ory. To customize Ory OAuth2 and OpenID Connect to work with your user database, you can follow the guide on [User login and consent flow](https://www.ory.sh/docs/oauth2-oidc/custom-login-consent/flow). This guide will walk you through the process of customizing Ory OAuth2 and OpenID Connect to work with your user database, login UI, and consent logic and UI. For running Ory Hydra against a SQL database, you can set the connection string as shown in the [Kubernetes Helm Chart](https://www.ory.sh/docs/hydra/self-hosted/kubernetes-helm-chart) documentation. Ory Hydra is OpenID certified and can be used as an OpenID Connect provider as mentioned in the [Compliance and certifications](https://www.ory.sh/docs/security-compliance/compliance-and-certifications) documentation. Please note that Ory Hydra is not an identity management system itself. It connects to your existing identity management system and is capable of issuing, in a secure and OpenID Certified manner, access, refresh, and ID tokens. I hope this helps! If you have any more questions, feel free to ask.
i
@chilly-king-10285 how do I do all of this in a local env first and not on a Kubernates ?
c
A message from kapa.ai
Sure, you can definitely set up Ory Hydra in a local environment first for testing purposes. Here are the steps you can follow: 1. Install Ory Hydra: You can install Ory Hydra on your local machine. If you're using Linux, you can use the following command to install Ory Hydra:
Copy code
bash bash <(curl <https://raw.githubusercontent.com/ory/meta/master/install.sh>) -d -b . hydra <version-you-want>   ./hydra help
You may want to move Ory Hydra to your `$PATH`:
Copy code
bash sudo mv ./hydra /usr/local/bin/   hydra help
For macOS and Windows, you can follow the instructions provided in the [installation guide](https://www.ory.sh/docs/hydra/self-hosted/install). 2. Configure Ory Hydra: After installation, you need to configure Ory Hydra to connect to your existing SQL database. You can do this by creating a configuration file (
hydra.yml
) and setting the DSN (Data Source Name) to your SQL database connection string. Here is an example:
Copy code
yaml dsn: <postgres://hydra:[email> protected]:5432/hydra?sslmode=disable&max_conns=20&max_idle_conns=4   urls:    self:    issuer: <https://oauth2.example.com>
3. Apply Migrations: After setting up the configuration, you need to apply migrations to your SQL database. You can do this using the following command:
Copy code
bash /opt/hydra/bin/hydra -c /opt/hydra/config/hydra.yml migrate sql -y <postgres://hydra:[email> protected]:5432/hydra?sslmode=disable
4. Run Ory Hydra: Finally, you can run Ory Hydra using the
serve
command:
Copy code
bash /opt/hydra/bin/hydra -c /opt/hydra/config/hydra.yml serve all
Please note that these steps are for a local setup and should not be used for production. For production, you should follow the [production guide](https://www.ory.sh/docs/hydra/self-hosted/deploy-hydra-example). I hope this helps! If you have any more questions, feel free to ask.