Skip to content
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

Add --origin Argument for Handling Single Page Application Refresh Tokens #99

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

so-lcain
Copy link

@so-lcain so-lcain commented Aug 26, 2024

This pull requests includes updates to roadlib's auth.py and roadrecon's gather.py. The changes add the argument --origin which appends a header origin value to refresh token requests which is required when using Single Page Application (SPA) refresh tokens such as the Azure portal or Office Online Application portal. Users obtain a refresh token from an authenticated browser session, supply the SPA client-id, and pass an '--origin' value such as 'https://portal.azure.com' so they can then obtain an access token. Example syntax when using a refresh token from the Azure portal : roadtx gettokens -c c44b4083-3bb0-49c1-b47d-974e53cbdf3c --origin "https://portal.azure.com" --refresh-token ""

These changes have been tested and allow running collections and obtaining tokens in hardened Azure environments where device-code flow, external applications, and Selenium browser implementations are not an option. Obtaining refresh tokens from a user's authenticated browser session logged into one of the portals and supplying it to obtain an access token makes for a simple and efficient workflow. The checktoken function of gather.py was modified to handle requesting a new token with the appropriate origin header value for collections in large tenants.

so-lcain and others added 8 commits August 21, 2024 15:09
Added origin attribute to be appended to HTTP requests when using Browser based tokens.
Added static origin values for Azure portal client ID.
Updated checktoken function to use authenticate_with_refresh_native and v2 custom methods instead of Microsoft adal.
Corrected try and except statements
Modify expire time to utilize token values returned from authenticate_with_refresh_token_native functions.
Improvements to more efficiently handle adding "Origin" header to Single Page Application token refresh requests. Removed static client id, implemented a static header for adal when self.origin is set in Auth.py, updated checktoken function in gather.py to use adal authorization with refresh token instead of native, removed unnecessary comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant