Skip to content

GUACAMOLE-2210: Add support for AAD authentication to RDP protocol.#633

Open
aleitner wants to merge 2 commits intoapache:staging/1.6.1from
aleitner:GUACAMOLE-2210-AAD
Open

GUACAMOLE-2210: Add support for AAD authentication to RDP protocol.#633
aleitner wants to merge 2 commits intoapache:staging/1.6.1from
aleitner:GUACAMOLE-2210-AAD

Conversation

@aleitner
Copy link
Copy Markdown
Contributor

  • Adds Azure AD (Entra ID) authentication support for RDP connections using FreeRDP 3's AadSecurity mode
  • Implements the OAuth2 authorization code flow server-side using libcurl to automate the Microsoft login sequence
  • Adds #include "config.h" to source files that were missing it, fixing struct member offset mismatches.

Authentication Flow

When security=aad is set on an RDP connection:

  1. FreeRDP initiates the AAD handshake and invokes the GetAccessToken callback with the required scope and Proof-of-Possession key
  2. The callback prompts for username/password via guac_argv if not already configured
  3. An OAuth2 authorization URL is built using the client ID from FreeRDP's GatewayAvdClientID setting and the common tenant endpoint
  4. The Microsoft login page is fetched via HTTP GET and the $Config JavaScript object is parsed for session tokens (sFT, sCtx, urlPost, canary, apiCanary)
  5. The GetCredentialType API is called to update server-side session state and obtain a fresh flow token
  6. Credentials are POSTed to the login endpoint with the required CSRF tokens. On success, Microsoft redirects to the native client URI with an authorization code
  7. The authorization code is exchanged for an access token at the token endpoint, including the Proof-of-Possession binding
  8. The access token is returned to FreeRDP, which completes the AAD-authenticated RDP session

Paired with apache/guacamole-client#1168

@aleitner
Copy link
Copy Markdown
Contributor Author

Didn't realize we don't have curl. This would require adding curl as a dependency

Copy link
Copy Markdown
Contributor

@necouchman necouchman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the build is failing with an error about the switch() statement and one of the enums.

Comment thread src/protocols/rdp/rdp.c
@aleitner
Copy link
Copy Markdown
Contributor Author

Looks like the build is failing with an error about the switch() statement and one of the enums.

Ahh whoops! I was testing with only freerdp3 as that's when AAD support was implemented. Just added a case to the switch for freerdp2 so that it errors if AAD is selected

Comment thread src/protocols/rdp/aad.c Outdated
Comment on lines +65 to +71
/**
* User-Agent string sent with all HTTP requests to Microsoft login endpoints.
* A browser-like UA is required to avoid "unsupported browser" responses.
*/
#define GUAC_AAD_USER_AGENT \
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 " \
"(KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we going to need to continually update this value to avoid being re-flagged as unsupported due to the claimed version being old?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is an insane idea ... but we could calculate the expected current Chrome release from the current date based on their published major release cadence ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Microsoft's endpoints don't appear to validate browser version freshness currently. On the other hand we could fetch the latest stable major version from Google's VersionHistory API:
https://versionhistory.googleapis.com/v1/chrome/platforms/linux/channels/stable/versions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made the changes to get the latest chrome version!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, phoning Google from within guacd is going to be a privacy issue. I don't think we can go this route.

@aleitner aleitner force-pushed the GUACAMOLE-2210-AAD branch from 7989a72 to 37b1d5a Compare April 1, 2026 21:13
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.

3 participants