Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Allow tokens with multiple audiences as long as one matches #285

Merged
merged 4 commits into from
Feb 3, 2022

Conversation

EngHabu
Copy link
Contributor

@EngHabu EngHabu commented Nov 9, 2021

Signed-off-by: Haytham Abuelfutuh [email protected]

TL;DR

Tested this using keycloak as an external auth server.
The token generated by keycloak come with account as audience and verified that with admin not configured with this audience rejects the token

{"json":{"src":"handlers.go:237"},"level":"info","msg":"Failed to parse Access Token from context. Will attempt to find IDToken. Error: invalid audience [account]","ts":"2022-02-02T15:43:42+05:30"}

Unit tests added for multiple audience.

Tried adding keycloak token mapper to generate multiple audience but couldn't get that to work . But this code works in all cases which are required for this ticket.

Type

  • Bug Fix
  • Feature
  • Plugin

Are all requirements met?

  • Code completed
  • Smoke tested
  • Unit tests added
  • Code documentation added
  • Any pending items have an associated Issue

Complete description

How did you fix the bug, make the feature etc. Link to any design docs etc

Tracking Issue

Remove the 'fixes' keyword if there will be multiple PRs to fix the linked issue

fixes flyteorg/flyte#1809

@EngHabu
Copy link
Contributor Author

EngHabu commented Nov 9, 2021

@pmahindrakar-oss this is roughly what's needed... feel free to validate and test though..

EngHabu and others added 2 commits February 2, 2022 16:20
Signed-off-by: Prafulla Mahindrakar <[email protected]>
@codecov
Copy link

codecov bot commented Feb 2, 2022

Codecov Report

Merging #285 (c761a3a) into master (c1b8fa4) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #285      +/-   ##
==========================================
+ Coverage   58.50%   58.53%   +0.02%     
==========================================
  Files         152      152              
  Lines       11018    11021       +3     
==========================================
+ Hits         6446     6451       +5     
+ Misses       3873     3872       -1     
+ Partials      699      698       -1     
Flag Coverage Δ
unittests 57.29% <100.00%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
auth/authzserver/provider.go 75.18% <100.00%> (+2.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c1b8fa4...c761a3a. Read the comment docs.

@pmahindrakar-oss
Copy link
Contributor

@EngHabu this is ready for review. Verified this using keycloak

kumare3
kumare3 previously approved these changes Feb 3, 2022
@kumare3
Copy link
Contributor

kumare3 commented Feb 3, 2022

Wait - should you change line# 177

Signed-off-by: Prafulla Mahindrakar <[email protected]>
@pmahindrakar-oss
Copy link
Contributor

Thanks @kumare3 for pointing that out. Adding the matched audience to the identity context now

@EngHabu EngHabu merged commit e61da89 into master Feb 3, 2022
@EngHabu EngHabu deleted the multiple-aud branch February 3, 2022 18:36
eapolinario pushed a commit that referenced this pull request Sep 6, 2023
* Allow tokens with multiple audiences as long as one matches

Signed-off-by: Haytham Abuelfutuh <[email protected]>

* Added unit tests

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Adding matched audience index in the context

Signed-off-by: Prafulla Mahindrakar <[email protected]>

* Update mocks

Signed-off-by: Prafulla Mahindrakar <[email protected]>

Co-authored-by: Prafulla Mahindrakar <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Housekeeping] FlyteAdmin Auth should allow multiple audiences as long as the one it's looking for is there
3 participants