Skip to content

Commit

Permalink
sdk: Use new api groups everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
arekkas committed Nov 18, 2018
1 parent 89f5960 commit 700a4a2
Show file tree
Hide file tree
Showing 267 changed files with 7,240 additions and 7,368 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ gen: gen-mocks gen-sql gen-sdk

gen-sdk:
swagger generate spec -m -o ./docs/api.swagger.json
swagger validate ./docs/api.swagger.json

rm -rf ./sdk/go/hydra/swagger
rm -rf ./sdk/js/swagger
Expand Down
16 changes: 16 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,22 @@ In order to [resolve table locking](https://github.com/ory/hydra/issues/1067) wh

### Breaking Changes

#### Swagger & SDK Restructuring

To better represent the public and admin endpoint, previous swagger tags (like oAuth2, jwks, ...) have been deprecated
in favor of tags `public` and `admin`. This has different impacts for the different code-generated client libraries.

##### Go

If you use the `hydra.SDK` interface only and the `hydra.NewSDK()` factory, everything will work as before. If you
rely on e.g. `hydra.NewOAuth2Api()`, you will be affected by this change.

##### Others

All method signatures stayed the same, but the factory names for instantiating the SDK client have changed. For example,
`hydra.NewOAuth2Api()` is now `hydra.NewAdminApi()` and `hydra.NewPublicApi()` - depending on which endpoints you need
to interact with.

#### JSON Web Token formatted Access Token data

Previously, extra fields coming from `session.access_token` where directly embedded in the OAuth 2.0 Access Token when
Expand Down
2 changes: 1 addition & 1 deletion client/sdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func TestClientSDK(t *testing.T) {
router := httprouter.New()
handler.SetRoutes(router)
server := httptest.NewServer(router)
c := hydra.NewOAuth2ApiWithBasePath(server.URL)
c := hydra.NewAdminApiWithBasePath(server.URL)
t.Run("case=client default scopes are set", func(t *testing.T) {
result, response, err := c.CreateOAuth2Client(hydra.OAuth2Client{
ClientId: "scoped",
Expand Down
66 changes: 33 additions & 33 deletions client/sql_migration_files.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cmd/cli/handler_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ func newClientHandler(c *config.Config) *ClientHandler {
}
}

func (h *ClientHandler) newClientManager(cmd *cobra.Command) *hydra.OAuth2Api {
c := hydra.NewOAuth2ApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
func (h *ClientHandler) newClientManager(cmd *cobra.Command) *hydra.AdminApi {
c := hydra.NewAdminApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
c.Configuration = configureClient(cmd, c.Configuration)
return c
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/handler_introspection.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func newIntrospectionHandler(c *config.Config) *IntrospectionHandler {
func (h *IntrospectionHandler) Introspect(cmd *cobra.Command, args []string) {
cmdx.ExactArgs(cmd, args, 1)

c := hydra.NewOAuth2ApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
c := hydra.NewAdminApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
c.Configuration = configureClient(cmd, c.Configuration)

clientID := flagx.MustGetString(cmd, "client-id")
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/handler_jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ type JWKHandler struct {
Config *config.Config
}

func (h *JWKHandler) newJwkManager(cmd *cobra.Command) *hydra.JsonWebKeyApi {
c := hydra.NewJsonWebKeyApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
func (h *JWKHandler) newJwkManager(cmd *cobra.Command) *hydra.AdminApi {
c := hydra.NewAdminApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
c.Configuration = configureClient(cmd, c.Configuration)
return c
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/cli/handler_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type TokenHandler struct {
Config *config.Config
}

func (h *TokenHandler) newTokenManager(cmd *cobra.Command) *hydra.OAuth2Api {
c := hydra.NewOAuth2ApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
func (h *TokenHandler) newTokenManager(cmd *cobra.Command) *hydra.AdminApi {
c := hydra.NewAdminApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
c.Configuration = configureClientWithoutAuth(cmd, c.Configuration)
return c
}
Expand All @@ -50,7 +50,7 @@ func newTokenHandler(c *config.Config) *TokenHandler {
func (h *TokenHandler) RevokeToken(cmd *cobra.Command, args []string) {
cmdx.ExactArgs(cmd, args, 1)

handler := hydra.NewOAuth2ApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
handler := hydra.NewPublicApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
handler.Configuration = configureClientWithoutAuth(cmd, handler.Configuration)

if clientID, clientSecret := flagx.MustGetString(cmd, "client-id"), flagx.MustGetString(cmd, "client-secret"); clientID == "" || clientSecret == "" {
Expand All @@ -70,7 +70,7 @@ Please provide a Client ID and Client Secret using flags --client-id and --clien
}

func (h *TokenHandler) FlushTokens(cmd *cobra.Command, args []string) {
handler := hydra.NewOAuth2ApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
handler := hydra.NewAdminApiWithBasePath(h.Config.GetClusterURLWithoutTailingSlashOrFail(cmd))
handler.Configuration = configureClient(cmd, handler.Configuration)
response, err := handler.FlushInactiveOAuth2Tokens(hydra.FlushInactiveOAuth2TokensRequest{
NotAfter: time.Now().Add(-flagx.MustGetDuration(cmd, "min-age")),
Expand Down
Loading

0 comments on commit 700a4a2

Please sign in to comment.