-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix (#1999) request url overwritten #2061
Closed
pietrygamat
wants to merge
5
commits into
usebruno:main
from
pietrygamat:bugfix/1999-request-url-overwritten
Closed
fix (#1999) request url overwritten #2061
pietrygamat
wants to merge
5
commits into
usebruno:main
from
pietrygamat:bugfix/1999-request-url-overwritten
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pietrygamat
changed the title
Bugfix/1999 request url overwritten
fix (#1999) request url overwritten
Apr 11, 2024
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
5 times, most recently
from
April 14, 2024 12:07
aabff55
to
85600d8
Compare
2 tasks
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
3 times, most recently
from
April 14, 2024 18:44
0257ef9
to
4e97648
Compare
5 tasks
This may be superseded by a more complete #2077. |
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
3 times, most recently
from
April 16, 2024 09:43
9db0485
to
f9a1e34
Compare
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
from
May 5, 2024 17:06
f9a1e34
to
4a58438
Compare
This was referenced May 5, 2024
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
3 times, most recently
from
May 7, 2024 18:04
363d357
to
bf9e6dd
Compare
2 tasks
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
from
June 2, 2024 16:11
bf9e6dd
to
b13260e
Compare
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
2 times, most recently
from
June 21, 2024 22:31
8a2221c
to
93a214e
Compare
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
from
July 26, 2024 17:34
93a214e
to
c2a3e89
Compare
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
from
August 22, 2024 22:53
c2a3e89
to
9130e4a
Compare
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
from
August 28, 2024 00:04
9130e4a
to
d3ad37e
Compare
Thanks for the work on this @pietrygamat ! We are reviewing this as a part of our broader effort to bring in OAuth2.0 interface improvements. |
…ad of api endpoint (usebruno#1999) Setting oauth2 authorization no longer equals overwriting user-specified data in a request. The pre-requests made to obtain oauth2 access_token are now separated from actual API request.
Results of oauth2 authorization flow (i.e. access_token but also refresh_token, id_token, scope or any other information returned from token request) are stored in a collection specific cache. It is persisted in the file system, and will be automatically reused when executing requests until the cache is purged (using Clear Cache button available in all related views).
…o be usable by scripts The new variable 'credentials' is now available in 'req' object. It is added automatically during request preparation if oauth2 method is used and is value is either evaluated or retrieved from collection oauth2 cache.
…vel Get Access Token action The actual the authorization request is now part of request preparation, and its response is returned for post-request script processing.
According to RFC6749 Section 7.1, The client MUST NOT use an access token if it does not understand the token type. At this point bruno only understands 'bearer' token_type.
pietrygamat
force-pushed
the
bugfix/1999-request-url-overwritten
branch
from
September 23, 2024 20:18
d3ad37e
to
2064cc8
Compare
Changes pulled into usebruno:feat/oauth2-improvements #3867 . This may be closed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR changes how oauth2 authorization behaves. The current behavior is that user defined request is in most part overwritten by bruno and replaced with request for access token (following the specific OAuth2 flow). After this change, the token request will be executed separately, and obtained access token will be used to modify the user request's Authorization header.
Credentials caching
In order to avoid renewing access tokens for each request, bruno will cache the authorization response data. This information typically contains:
access_token
,token_type
and some optional fields:refresh_token
,expires_in
,scope
,session
or whatever authrization server decides to include. The cached data is collection specific, and will be used if present. It may be cleared using clear cache button, together with other oauth2 session state.Automatically using token if token_type is bearer
After obtaining access token from authorization server or from cache, bruno will verify what is its
token_type
. At this point bruno understandsbearer
type, so if that's it - the user's request will be modified - theAuthorization Bearer $access_token
header will be added automatically, so the request should be successful. In cases where the token is of different type (e.g. mac encrypted) - bruno will not attempt anything, but user is free to use scripting capabilities to work with the token in any way they see fit. Support for other token_types may be added in the future, if there's a demand.Scripting
The token (and other data from authrization server response) are also available in scripting engine. The
req
object now includes the.credentials
field where they can be accessed in post-request script (and if #2249 is fixed, also in pre-request scripts). E.g. this is possible:More work is required for feature completeness:
Contribution Checklist:
resolves #1999