Skip to content

Commit

Permalink
refactor(sdk): JSON Web Key SDK API
Browse files Browse the repository at this point in the history
BREAKING CHANGE: SDK naming has changed for the following operations:

```patch
ory.
-   V0alpha2Api.DiscoverJsonWebKeys(context.Background()).
+   WellknownApi.DiscoverJsonWebKeys(context.Background()).
    Execute()

ory.
-   V0alpha2Api.AdminGetJsonWebKeySet(context.Background(), setID).
+	JwkApi.GetJsonWebKeySet(context.Background(), setID).
    Execute()

ory.
-   V0alpha2Api.AdminGetJsonWebKey(context.Background(), setID, keyID).
+   JwkApi.GetJsonWebKey(context.Background(), setID, keyID).
    Execute()

ory.
-   V0alpha2Api.AdminCreateJsonWebKeySet(context.Background(), setID).
-   AdminCreateJsonWebKeySetBody(hydra.AdminCreateJsonWebKeySetBody{
-       Alg: "RS256",
-       Use: "sig",
+   JwkApi.CreateJsonWebKeySet(context.Background(), setID).
+   CreateJsonWebKeySet(hydra.CreateJsonWebKeySet{
+       Alg: "RS256",
+       Use: "sig",
    }).Execute()

ory.
-   V0alpha2Api.AdminUpdateJsonWebKey(context.Background(), setID, keyID).
+   JwkApi.SetJsonWebKey(context.Background(), setID, keyID).
    JsonWebKey(jsonWebKey).Execute()
ory.
-   V0alpha2Api.AdminUpdateJsonWebKeySet(context.Background(), setID).
+   JwkApi.SetJsonWebKeySet(context.Background(), setID).
    JsonWebKeySet(jsonWebKeySet).Execute()

ory.
-   V0alpha2Api.AdminDeleteJsonWebKey(context.Background(), setID, keyID).
    JwkApi.DeleteJsonWebKey(context.Background(), setID, keyID).
    Execute()
ory.
-   V0alpha2Api.AdminDeleteJsonWebKeySet(context.Background(), setID).
    JwkApi.DeleteJsonWebKeySet(context.Background(), setID).
    Execute()
```
  • Loading branch information
aeneasr committed Oct 11, 2022
1 parent e800002 commit 06d565e
Show file tree
Hide file tree
Showing 29 changed files with 2,370 additions and 2,258 deletions.
2 changes: 1 addition & 1 deletion cmd/cmd_create_jwks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewCreateJWKSCmd() *cobra.Command {
}

//nolint:bodyclose
jwks, _, err := m.V0alpha2Api.AdminCreateJsonWebKeySet(context.Background(), args[0]).AdminCreateJsonWebKeySetBody(hydra.AdminCreateJsonWebKeySetBody{
jwks, _, err := m.JwkApi.CreateJsonWebKeySet(context.Background(), args[0]).CreateJsonWebKeySet(hydra.CreateJsonWebKeySet{
Alg: flagx.MustGetString(cmd, alg),
Kid: kid,
Use: flagx.MustGetString(cmd, use),
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_delete_jwks.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func NewDeleteJWKSCommand() *cobra.Command {
)

for _, c := range args {
_, err = m.V0alpha2Api.AdminDeleteJsonWebKeySet(context.Background(), c).Execute() //nolint:bodyclose
_, err = m.JwkApi.DeleteJsonWebKeySet(context.Background(), c).Execute() //nolint:bodyclose
if err != nil {
return cmdx.PrintOpenAPIError(cmd, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_get_jwks.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func NewGetJWKSCmd() *cobra.Command {

var sets outputJSONWebKeyCollection
for _, set := range args {
key, _, err := m.V0alpha2Api.AdminGetJsonWebKeySet(cmd.Context(), set).Execute() //nolint:bodyclose
key, _, err := m.JwkApi.GetJsonWebKeySet(cmd.Context(), set).Execute() //nolint:bodyclose
if err != nil {
return cmdx.PrintOpenAPIError(cmd, err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cmd_import_jwk.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ the imported keys will be added to that set. Otherwise, a new set will be create
failed := make(map[string]error)
for src, kk := range keys {
for _, k := range kk {
result, _, err := m.V0alpha2Api.AdminUpdateJsonWebKey(cmd.Context(), k.Kid, set).JsonWebKey(k).Execute() //nolint:bodyclose
result, _, err := m.JwkApi.SetJsonWebKey(cmd.Context(), k.Kid, set).JsonWebKey(k).Execute() //nolint:bodyclose
if err != nil {
failed[src] = cmdx.PrintOpenAPIError(cmd, err)
continue
Expand Down
18 changes: 9 additions & 9 deletions consent/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (h *Handler) revokeOAuth2LoginSessions(w http.ResponseWriter, r *http.Reque
w.WriteHeader(http.StatusNoContent)
}

// Get OAuth 2.0 Login Request Parameters
// Get OAuth 2.0 Login Request
//
// swagger:parameters getOAuth2LoginRequest
type getOAuth2LoginRequest struct {
Expand Down Expand Up @@ -335,7 +335,7 @@ func (h *Handler) getOAuth2LoginRequest(w http.ResponseWriter, r *http.Request,
h.r.Writer().Write(w, r, request)
}

// Accept OAuth 2.0 Login Request Parameters
// Accept OAuth 2.0 Login Request
//
// swagger:parameters acceptOAuth2LoginRequest
type acceptOAuth2LoginRequest struct {
Expand Down Expand Up @@ -437,7 +437,7 @@ func (h *Handler) acceptOAuth2LoginRequest(w http.ResponseWriter, r *http.Reques
})
}

// Reject OAuth 2.0 Login Request Parameters
// Reject OAuth 2.0 Login Request
//
// swagger:parameters rejectOAuth2LoginRequest
type rejectOAuth2LoginRequest struct {
Expand Down Expand Up @@ -524,7 +524,7 @@ func (h *Handler) rejectOAuth2LoginRequest(w http.ResponseWriter, r *http.Reques
})
}

// Get OAuth 2.0 Consent Request Parameters
// Get OAuth 2.0 Consent Request
//
// swagger:parameters getOAuth2ConsentRequest
type getOAuth2ConsentRequest struct {
Expand Down Expand Up @@ -596,7 +596,7 @@ func (h *Handler) getOAuth2ConsentRequest(w http.ResponseWriter, r *http.Request
h.r.Writer().Write(w, r, request)
}

// Accept OAuth 2.0 Consent Request Parameters
// Accept OAuth 2.0 Consent Request
//
// swagger:parameters acceptOAuth2ConsentRequest
type acceptOAuth2ConsentRequest struct {
Expand Down Expand Up @@ -689,7 +689,7 @@ func (h *Handler) acceptOAuth2ConsentRequest(w http.ResponseWriter, r *http.Requ
})
}

// Reject OAuth 2.0 Consent Request Parameters
// Reject OAuth 2.0 Consent Request
//
// swagger:parameters rejectOAuth2ConsentRequest
type adminRejectOAuth2ConsentRequest struct {
Expand Down Expand Up @@ -782,7 +782,7 @@ func (h *Handler) rejectOAuth2ConsentRequest(w http.ResponseWriter, r *http.Requ
})
}

// Accept OAuth 2.0 Logout Request Parameters
// Accept OAuth 2.0 Logout Request
//
// swagger:parameters acceptOAuth2LogoutRequest
type acceptOAuth2LogoutRequest struct {
Expand Down Expand Up @@ -826,7 +826,7 @@ func (h *Handler) acceptOAuth2LogoutRequest(w http.ResponseWriter, r *http.Reque
})
}

// Reject OAuth 2.0 Logout Request Parameters
// Reject OAuth 2.0 Logout Request
//
// swagger:parameters rejectOAuth2LogoutRequest
type rejectOAuth2LogoutRequest struct {
Expand Down Expand Up @@ -866,7 +866,7 @@ func (h *Handler) rejectOAuth2LogoutRequest(w http.ResponseWriter, r *http.Reque
w.WriteHeader(http.StatusNoContent)
}

// Get OAuth 2.0 Logout Request Parameters
// Get OAuth 2.0 Logout Request
//
// swagger:parameters getOAuth2LogoutRequest
type getOAuth2LogoutRequest struct {
Expand Down
25 changes: 20 additions & 5 deletions consent/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,37 @@ type oAuth2ConsentSessions []OAuth2ConsentSession
//
// swagger:model oAuth2ConsentSession
type OAuth2ConsentSession struct {
// Named ID because of pop
ID string `json:"-" db:"challenge"`

// Scope Granted
//
// GrantScope sets the scope the user authorized the client to use. Should be a subset of `requested_scope`.
GrantedScope sqlxx.StringSliceJSONFormat `json:"grant_scope" db:"granted_scope"`

// Audience Granted
//
// GrantedAudience sets the audience the user authorized the client to use. Should be a subset of `requested_access_token_audience`.
GrantedAudience sqlxx.StringSliceJSONFormat `json:"grant_access_token_audience" db:"granted_at_audience"`

// Session Details
//
// Session allows you to set (optional) session data for access and ID tokens.
Session *AcceptOAuth2ConsentRequestSession `json:"session" db:"-"`

// Remember Consent
//
// Remember, if set to true, tells ORY Hydra to remember this consent authorization and reuse it if the same
// client asks the same user for the same, or a subset of, scope.
Remember bool `json:"remember" db:"remember"`

// Remember Consent For
//
// RememberFor sets how long the consent authorization should be remembered for in seconds. If set to `0`, the
// authorization will be remembered indefinitely.
RememberFor int `json:"remember_for" db:"remember_for"`

// Consent Handled At
//
// HandledAt contains the timestamp the consent request was handled.
HandledAt sqlxx.NullTime `json:"handled_at" db:"handled_at"`

Expand All @@ -242,10 +253,14 @@ type OAuth2ConsentSession struct {
// the flow.
WasHandled bool `json:"-" db:"was_used"`

ConsentRequest *OAuth2ConsentRequest `json:"consent_request" db:"-"`
Error *RequestDeniedError `json:"-" db:"error"`
RequestedAt time.Time `json:"-" db:"requested_at"`
AuthenticatedAt sqlxx.NullTime `json:"-" db:"authenticated_at"`
// Consent Request
//
// The consent request that lead to this consent session.
ConsentRequest *OAuth2ConsentRequest `json:"consent_request" db:"-"`

Error *RequestDeniedError `json:"-" db:"error"`
RequestedAt time.Time `json:"-" db:"requested_at"`
AuthenticatedAt sqlxx.NullTime `json:"-" db:"authenticated_at"`

SessionIDToken sqlxx.MapStringInterface `db:"session_id_token" json:"-"`
SessionAccessToken sqlxx.MapStringInterface `db:"session_access_token" json:"-"`
Expand Down
8 changes: 6 additions & 2 deletions internal/httpclient/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
.travis.yml
README.md
api/openapi.yaml
api_jwk.go
api_metadata.go
api_o_auth2.go
api_oidc.go
api_v0alpha2.go
api_wellknown.go
client.go
configuration.go
docs/AcceptOAuth2ConsentRequest.md
docs/AcceptOAuth2ConsentRequestSession.md
docs/AcceptOAuth2LoginRequest.md
docs/AdminCreateJsonWebKeySetBody.md
docs/AdminTrustOAuth2JwtGrantIssuerBody.md
docs/CreateJsonWebKeySet.md
docs/ErrorOAuth2.md
docs/GenericError.md
docs/GetVersion200Response.md
Expand All @@ -27,6 +29,7 @@ docs/IsReady503Response.md
docs/JsonPatch.md
docs/JsonWebKey.md
docs/JsonWebKeySet.md
docs/JwkApi.md
docs/MetadataApi.md
docs/OAuth2AccessRequest.md
docs/OAuth2Api.md
Expand Down Expand Up @@ -56,14 +59,15 @@ docs/TrustedOAuth2JwtGrantIssuer.md
docs/TrustedOAuth2JwtGrantJsonWebKey.md
docs/V0alpha2Api.md
docs/Version.md
docs/WellknownApi.md
git_push.sh
go.mod
go.sum
model_accept_o_auth2_consent_request.go
model_accept_o_auth2_consent_request_session.go
model_accept_o_auth2_login_request.go
model_admin_create_json_web_key_set_body.go
model_admin_trust_o_auth2_jwt_grant_issuer_body.go
model_create_json_web_key_set.go
model_error_o_auth2.go
model_generic_error.go
model_get_version_200_response.go
Expand Down
Loading

0 comments on commit 06d565e

Please sign in to comment.