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

feat(oidc): allow additional audience based on scope in device auth #7685

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

muhlemmer
Copy link
Contributor

@muhlemmer muhlemmer commented Apr 1, 2024

This change in device authorization adds the ability to extend the audience based on the project IDs, using the reserved scope:

urn:zitadel:iam:org:project:id:{projectid}:aud

This unifies behavior with "regular" auth requests.

Closes zitadel/oidc#425

Definition of Ready

  • I am happy with the code
  • Short description of the feature/issue is added in the pr description
  • PR is linked to the corresponding user story
  • Acceptance criteria are met
  • All open todos and follow ups are defined in a new ticket and justified
  • Deviations from the acceptance criteria and design are agreed with the PO and documented.
  • No debug or dead code
  • My code has no repetitions
  • Critical parts are tested automatically
  • Where possible E2E tests are implemented
  • Documentation/examples are up-to-date (no changes needed)
  • All non-functional requirements are met
  • Functionality of the acceptance criteria is checked manually on the dev system.

Tests

As there a no integration tests for device auth, I've tested it manually using the OIDC client example:

export ISSUER="http://localhost:9000" CLIENT_ID="257793310637228036@tests" SCOPES="email profile openid 	urn:zitadel:iam:org:project:id:259254020357488642:aud urn:zitadel:iam:org:project:id:259254317079330818:aud"
go run ./example/client/device

With the returned opaque access token I called introspection:

curl -L -X POST 'http://localhost:9000/oauth/v2/introspect' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -u '260838903370547202@tests:SNpRaExIEzr5F7OcYC1h1fDtQIRTNVaS13gAOh0bJxFAPAh0czw8yuKds47JnIlg' \
  -d token=35Lc_CD6QUB1BXYKOMQ4e4BN51eDbcssZyMiRv-qg1vteudPqoG54SBHzLOmsWndfYnX0Pg | jq

Result:

{
  "active": true,
  "scope": "email profile openid urn:zitadel:iam:org:project:id:259254020357488642:aud urn:zitadel:iam:org:project:id:259254317079330818:aud",
  "client_id": "257793310637228036@tests",
  "token_type": "Bearer",
  "exp": 1712090743,
  "iat": 1712047543,
  "nbf": 1712047543,
  "sub": "257786991247228932",
  "aud": [
    "257790446061813762@tests",
    "257793310637228036@tests",
    "259239924006453250@tests",
    "260838903370547202@tests",
    "257790403229515778",
    "259254020357488642",
    "259254317079330818"
  ],
  "iss": "http://localhost:9000",
  "jti": "260972184896274434",
  "username": "zitadel-admin@zitadel.localhost",
  "name": "ZITADEL Admin",
  "given_name": "ZITADEL",
  "family_name": "Admin",
  "locale": "en",
  "updated_at": 1710149020,
  "preferred_username": "zitadel-admin@zitadel.localhost",
  "email": "zitadel-admin@zitadel.localhost",
  "email_verified": true
}

And rerunning the above example with the application configured for JWT access token, gives the following access token claims:

{
  "iss": "http://localhost:9000",
  "sub": "257786991247228932",
  "aud": [
    "257790446061813762@tests",
    "257793310637228036@tests",
    "259239924006453250@tests",
    "260838903370547202@tests",
    "257790403229515778",
    "259254020357488642",
    "259254317079330818"
  ],
  "exp": 1712091031,
  "iat": 1712047831,
  "nbf": 1712047831,
  "jti": "260972668080095234"
}

Copy link

vercel bot commented Apr 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 1, 2024 3:35pm

@muhlemmer muhlemmer changed the title feat(oidc): allow additional audience based on scope feat(oidc): allow additional audience based on scope in device auth Apr 2, 2024
@muhlemmer muhlemmer marked this pull request as ready for review April 2, 2024 08:56
@muhlemmer muhlemmer requested a review from livio-a April 2, 2024 09:23
@muhlemmer muhlemmer merged commit 5b3946b into main Apr 3, 2024
26 checks passed
@muhlemmer muhlemmer deleted the feat-device-audience branch April 3, 2024 06:06
Copy link

🎉 This PR is included in version 2.50.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

allow to set audiences for device authorization
2 participants