Hydra client library

118 views
Skip to first unread message

Mohamedh Fazal

unread,
Jun 11, 2016, 6:04:24 AM6/11/16
to ory-hydra
Hi,

First, sorry about the delay. I've been busy at work figuring out how to integrate access control ( most probably Hydra )  and college.

I wanted to quickly push this to public so that you guys can comment and we could settle on the API first. 

I've modified  Jan's example a little to show initialization of client. Nothing is settled and I want library API to be very solid before doing anything else.

I might have something very stupid in there as I'm also figuring things out as I go.



Aeneas Rekkas

unread,
Jun 12, 2016, 4:09:25 AM6/12/16
to ory-...@googlegroups.com

Hey you don't need to write HTTP clients for go. Hydra ships with tested client libraries for Go. Here for example:

https://github.com/ory-am/hydra/blob/master/jwk/manager_http.go

Sorry that this isn't documented anywhere..

--
You received this message because you are subscribed to the Google Groups "ory-hydra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ory-hydra+...@googlegroups.com.
To post to this group, send email to ory-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ory-hydra/cdc3ec6b-b71e-4a3b-9b78-6658fee01c36%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohamedh Fazal

unread,
Jun 12, 2016, 4:57:38 AM6/12/16
to ory-hydra
shoot! I'm very confused ATM. In thread "Example Identity Provider in GO", Jan mentioned "Hydra Client Library"

I'm not sure what it means anymore. 

Aeneas Rekkas

unread,
Jun 12, 2016, 4:59:22 AM6/12/16
to ory-...@googlegroups.com

You will need to implement some functionality like getting an access token for the APIs :) But you don't need to implement handlers for most of them!

So you're on the right path but it would be smarter to wire together the HTTP managers from hydra instead of writing your own :)

Mohamedh Fazal

unread,
Jun 12, 2016, 5:23:58 AM6/12/16
to ory-hydra
I think it's better I hold this for the moment till I understand the use-case better. Because I'm kind of doing it blind right now. 
I think it'll be better done when I understand the usage POV. What do you think?

Mohamedh Fazal

unread,
Jun 12, 2016, 6:03:00 AM6/12/16
to ory-hydra
@aeneas I just checked your code. You've done almost everything :), I'm wondering why one would need a separate library for it. Do you think it's a good idea?

Good thing I didn't waste too much time on it.

On Sunday, June 12, 2016 at 1:59:22 PM UTC+5, aeneas wrote:

Aeneas Rekkas

unread,
Jun 12, 2016, 7:06:43 AM6/12/16
to ory-...@googlegroups.com

You could create a struct with embedded fields:

struct HTTPClient {

    *jwk.HTTPManager

    //...

}


and have a method like `Connect(id, secret, endpoint string)`. With a little documentation we could easily add that to the main repository for others to use.

Mohamedh Fazal

unread,
Jun 12, 2016, 7:11:30 AM6/12/16
to ory-hydra
:) That is exactly what I did after you linked the code. Thanks for that.

Aeneas Rekkas

unread,
Jun 12, 2016, 7:21:42 AM6/12/16
to ory-...@googlegroups.com

Perfect :) I thought of implementing this in something like https://thrift.apache.org/ and compile the client code for all languages.

If you're interested to look at this, I welcome any help :)

Mohamedh Fazal

unread,
Jun 12, 2016, 7:49:24 AM6/12/16
to ory-hydra
I will have a look.

Jan Olszak

unread,
Jun 12, 2016, 7:21:59 PM6/12/16
to ory-hydra
Hi,
I didn't know about GO clients in Hydra. I used hydra-idp-react as an example and that was probably my mistake.

Is warden's http api also wrapped in a client GO library?

Aeneas Rekkas

unread,
Jun 13, 2016, 4:06:27 AM6/13/16
to ory-...@googlegroups.com

Jan Olszak

unread,
Jun 13, 2016, 4:58:58 AM6/13/16
to Aeneas Rekkas, ory-...@googlegroups.com
Daaaaaaamn.. That's awesome.

You should definitely document this - it makes integrating with hydra a different story.

Can you create one package with one hydra-client that Resource Server and IdP can use? 


Aeneas Rekkas

unread,
Jun 13, 2016, 5:35:41 AM6/13/16
to Jan Olszak, ory-...@googlegroups.com
yes this is planned for the beta3 release :)

fazal

unread,
Jun 13, 2016, 6:07:28 AM6/13/16
to ory-hydra
I've removed all my API calls and embedded HTTPManager's from ory-am/hydra. 

Client is really thin now and I'm not sure what else I can put in there.

Aeneas Rekkas

unread,
Jun 13, 2016, 6:10:50 AM6/13/16
to fazal, ory-hydra
LGTM

you could probably even remove the wrapping structs like


type oauthClientsService struct {
*client.HTTPManager
}


and just do


type Hydra struct {
http         *http.Client
clusterURL   *url.URL
clientID     string
clientSecret string
skipSSL      bool

credentials clientcredentials.Config

Client   *client.HTTPManager
        // ….
}


--
You received this message because you are subscribed to the Google Groups "ory-hydra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ory-hydra+...@googlegroups.com.
To post to this group, send email to ory-...@googlegroups.com.

fazal

unread,
Jun 13, 2016, 6:19:56 AM6/13/16
to ory-hydra
Oh yes! :) excuse my ignorance.

Aeneas Rekkas

unread,
Jun 13, 2016, 6:20:26 AM6/13/16
to fazal, ory-hydra
nothing to worry about :)

Jan Olszak

unread,
Jun 29, 2016, 5:11:58 PM6/29/16
to Aeneas Rekkas, fazal, ory-hydra
@Mohamedh So is your library ready? I'd gladly use it in the idp.

fazal

unread,
Jun 30, 2016, 3:55:19 AM6/30/16
to ory-hydra
It's as ready as the HTTP Manager's in hydra. It's just a thin wrapper. 

Ideally I'd like to see this in hydra repository itself, since it's good to have an official client library and 99% of code is already in their. 

Aeneas Rekkas

unread,
Jun 30, 2016, 4:17:37 AM6/30/16
to ory-...@googlegroups.com

feel free to create a PR for it :)

fazal

unread,
Jun 30, 2016, 4:58:42 AM6/30/16
to ory-hydra
Nice :), biggest challenge is naming this

Several options:

1. ory-am/hydra/hydra (there is a stutter in package name, but not when using the package).

2. ory-am/hydra/hydra-client (since 'client' is already taken, but keep the package name as 'hydra').

3. move main.go in ory-am/hydra to ory-am/hydra/hydra and keep client libraries at root with the package name hydra.

Aeneas Rekkas

unread,
Jun 30, 2016, 5:11:23 AM6/30/16
to ory-...@googlegroups.com

why not simply ory-am/hydra/client.go ? i'm not sure if it's possible to import main packages though.

fazal

unread,
Jun 30, 2016, 5:21:15 AM6/30/16
to ory-hydra
That is the 3rd option I mentioned.

It's not possible. we will have to move main.go somewhere in that case. 

Aeneas Rekkas

unread,
Jun 30, 2016, 5:47:43 AM6/30/16
to ory-...@googlegroups.com

i see,

how about `ory-am/hydra/sdk`?

Reply all
Reply to author
Forward
0 new messages