Skip to content

Commit

Permalink
chore: synchronize workspaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aeneasr committed Dec 28, 2023
1 parent d70d56a commit 0b8c3f7
Show file tree
Hide file tree
Showing 9 changed files with 180 additions and 6 deletions.
5 changes: 4 additions & 1 deletion consent/csrf.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
package consent

import (
"github.com/ory/hydra/v2/flow"
"net/http"
"strings"
"time"

"github.com/ory/hydra/v2/flow"

"github.com/gorilla/sessions"

"github.com/ory/fosite"
Expand All @@ -19,6 +20,8 @@ import (
"github.com/ory/x/mapx"
)

// WARNING - changes in this file need to be mirrored elsewhere.

func createCsrfSession(w http.ResponseWriter, r *http.Request, conf x.CookieConfigProvider, store sessions.Store, name string, csrfValue string, maxAge time.Duration) error {
// Errors can be ignored here, because we always get a session back. Error typically means that the
// session doesn't exist yet.
Expand Down
10 changes: 8 additions & 2 deletions flow/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ func (f *Flow) HandleLoginRequest(h *HandledLoginRequest) error {
} else {
f.State = FlowStateLoginUnused
}

if f.Context != nil {
f.Context = h.Context
}

f.ID = h.ID
f.Subject = h.Subject
f.ForceSubjectIdentifier = h.ForceSubjectIdentifier
Expand All @@ -301,7 +306,6 @@ func (f *Flow) HandleLoginRequest(h *HandledLoginRequest) error {
f.LoginExtendSessionLifespan = h.ExtendSessionLifespan
f.ACR = h.ACR
f.AMR = h.AMR
f.Context = h.Context
f.LoginWasUsed = h.WasHandled
f.LoginAuthenticatedAt = h.AuthenticatedAt
return nil
Expand Down Expand Up @@ -394,7 +398,9 @@ func (f *Flow) HandleConsentRequest(r *AcceptOAuth2ConsentRequest) error {
f.ConsentHandledAt = r.HandledAt
f.ConsentWasHandled = r.WasHandled
f.ConsentError = r.Error
f.Context = r.Context
if r.Context != nil {
f.Context = r.Context
}

if r.Session != nil {
f.SessionIDToken = r.Session.IDToken
Expand Down
7 changes: 7 additions & 0 deletions internal/httpclient/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1896,6 +1896,9 @@ components:
type: object
acceptOAuth2ConsentRequest:
properties:
context:
title: "JSONRawMessage represents a json.RawMessage that works well with\
\ JSON, SQL, and Swagger."
grant_access_token_audience:
items:
type: string
Expand Down Expand Up @@ -3272,6 +3275,7 @@ components:
session:
access_token: ""
id_token: ""
context: ""
grant_access_token_audience:
- grant_access_token_audience
- grant_access_token_audience
Expand All @@ -3283,6 +3287,9 @@ components:
properties:
consent_request:
$ref: '#/components/schemas/oAuth2ConsentRequest'
context:
title: "JSONRawMessage represents a json.RawMessage that works well with\
\ JSON, SQL, and Swagger."
expires_at:
$ref: '#/components/schemas/oAuth2ConsentSession_expires_at'
grant_access_token_audience:
Expand Down
36 changes: 36 additions & 0 deletions internal/httpclient/docs/AcceptOAuth2ConsentRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Context** | Pointer to **interface{}** | | [optional]
**GrantAccessTokenAudience** | Pointer to **[]string** | | [optional]
**GrantScope** | Pointer to **[]string** | | [optional]
**HandledAt** | Pointer to **time.Time** | | [optional]
Expand All @@ -30,6 +31,41 @@ NewAcceptOAuth2ConsentRequestWithDefaults instantiates a new AcceptOAuth2Consent
This constructor will only assign default values to properties that have it defined,
but it doesn't guarantee that properties required by API are set

### GetContext

`func (o *AcceptOAuth2ConsentRequest) GetContext() interface{}`

GetContext returns the Context field if non-nil, zero value otherwise.

### GetContextOk

`func (o *AcceptOAuth2ConsentRequest) GetContextOk() (*interface{}, bool)`

GetContextOk returns a tuple with the Context field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetContext

`func (o *AcceptOAuth2ConsentRequest) SetContext(v interface{})`

SetContext sets Context field to given value.

### HasContext

`func (o *AcceptOAuth2ConsentRequest) HasContext() bool`

HasContext returns a boolean if a field has been set.

### SetContextNil

`func (o *AcceptOAuth2ConsentRequest) SetContextNil(b bool)`

SetContextNil sets the value for Context to be an explicit nil

### UnsetContext
`func (o *AcceptOAuth2ConsentRequest) UnsetContext()`

UnsetContext ensures that no value is present for Context, not even an explicit nil
### GetGrantAccessTokenAudience

`func (o *AcceptOAuth2ConsentRequest) GetGrantAccessTokenAudience() []string`
Expand Down
36 changes: 36 additions & 0 deletions internal/httpclient/docs/OAuth2ConsentSession.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ConsentRequest** | Pointer to [**OAuth2ConsentRequest**](OAuth2ConsentRequest.md) | | [optional]
**Context** | Pointer to **interface{}** | | [optional]
**ExpiresAt** | Pointer to [**OAuth2ConsentSessionExpiresAt**](OAuth2ConsentSessionExpiresAt.md) | | [optional]
**GrantAccessTokenAudience** | Pointer to **[]string** | | [optional]
**GrantScope** | Pointer to **[]string** | | [optional]
Expand Down Expand Up @@ -57,6 +58,41 @@ SetConsentRequest sets ConsentRequest field to given value.

HasConsentRequest returns a boolean if a field has been set.

### GetContext

`func (o *OAuth2ConsentSession) GetContext() interface{}`

GetContext returns the Context field if non-nil, zero value otherwise.

### GetContextOk

`func (o *OAuth2ConsentSession) GetContextOk() (*interface{}, bool)`

GetContextOk returns a tuple with the Context field if it's non-nil, zero value otherwise
and a boolean to check if the value has been set.

### SetContext

`func (o *OAuth2ConsentSession) SetContext(v interface{})`

SetContext sets Context field to given value.

### HasContext

`func (o *OAuth2ConsentSession) HasContext() bool`

HasContext returns a boolean if a field has been set.

### SetContextNil

`func (o *OAuth2ConsentSession) SetContextNil(b bool)`

SetContextNil sets the value for Context to be an explicit nil

### UnsetContext
`func (o *OAuth2ConsentSession) UnsetContext()`

UnsetContext ensures that no value is present for Context, not even an explicit nil
### GetExpiresAt

`func (o *OAuth2ConsentSession) GetExpiresAt() OAuth2ConsentSessionExpiresAt`
Expand Down
43 changes: 40 additions & 3 deletions internal/httpclient/model_accept_o_auth2_consent_request.go

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

37 changes: 37 additions & 0 deletions internal/httpclient/model_o_auth2_consent_session.go

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

6 changes: 6 additions & 0 deletions spec/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
},
"acceptOAuth2ConsentRequest": {
"properties": {
"context": {
"$ref": "#/components/schemas/JSONRawMessage"
},
"grant_access_token_audience": {
"$ref": "#/components/schemas/StringSliceJSONFormat"
},
Expand Down Expand Up @@ -914,6 +917,9 @@
"consent_request": {
"$ref": "#/components/schemas/oAuth2ConsentRequest"
},
"context": {
"$ref": "#/components/schemas/JSONRawMessage"
},
"expires_at": {
"properties": {
"access_token": {
Expand Down
6 changes: 6 additions & 0 deletions spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2173,6 +2173,9 @@
"type": "object",
"title": "The request payload used to accept a consent request.",
"properties": {
"context": {
"$ref": "#/definitions/JSONRawMessage"
},
"grant_access_token_audience": {
"$ref": "#/definitions/StringSliceJSONFormat"
},
Expand Down Expand Up @@ -2934,6 +2937,9 @@
"consent_request": {
"$ref": "#/definitions/oAuth2ConsentRequest"
},
"context": {
"$ref": "#/definitions/JSONRawMessage"
},
"grant_access_token_audience": {
"$ref": "#/definitions/StringSliceJSONFormat"
},
Expand Down

0 comments on commit 0b8c3f7

Please sign in to comment.