Skip to content

Conversation

@simonkurtz-MSFT
Copy link
Member

Resolves #9

@simonkurtz-MSFT simonkurtz-MSFT self-assigned this May 29, 2025
@simonkurtz-MSFT simonkurtz-MSFT requested a review from Copilot May 29, 2025 22:34
@github-actions
Copy link

Python 3.12 Test Results

90 tests  +3   90 ✅ +3   1s ⏱️ ±0s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 027c318. ± Comparison against base commit 02c0307.

@github-actions
Copy link

Python 3.13 Test Results

90 tests  +3   90 ✅ +3   0s ⏱️ -1s
 1 suites ±0    0 💤 ±0 
 1 files   ±0    0 ❌ ±0 

Results for commit 027c318. ± Comparison against base commit 02c0307.

@simonkurtz-MSFT simonkurtz-MSFT added the enhancement New feature or request label May 29, 2025
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces the authX sample to demonstrate authentication and role‐based authorization using JWTs with API Management. It also adds utility functions and tests to support signing key generation and updates several modules to integrate the new sample.

  • Added a new JWT-based authentication sample (authX) with accompanying Bicep templates and Jupyter notebook.
  • Introduced a generate_signing_key utility function and tests.
  • Updated APIM requests handling and new JWT token classes.

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/python/test_utils.py Added a test case for the new generate_signing_key function.
tests/python/test_apimrequests.py Added tests for header property mutations in APIM requests.
shared/python/utils.py Integrated generate_signing_key function and added traceback printing in error handling.
shared/python/apimtypes.py Introduced a NamedValue data class and added testing role IDs.
shared/python/apimrequests.py Modified header storage and updated the singlePost method signature.
shared/python/apimjwt.py Added JwtPayload and SymmetricJwtToken classes for JWT creation and signing.
shared/bicep/modules/apim/v1/*.bicep Added/updated Bicep modules for named values and API resources.
samples/authX/* Added the new authX sample, including policies, Bicep templates, and a Jupyter notebook.
README.md Updated documentation to include the new AuthX sample.

Comment on lines +255 to +261

def __init__(self, name: str, value: str, isSecret: bool = False):
self.name = name
self.value = value
self.isSecret = isSecret


Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] The NamedValue class is decorated with @DataClass but also defines an explicit init without additional logic. Consider removing the explicit init to leverage dataclass auto-generation and improve maintainability.

Suggested change
def __init__(self, name: str, value: str, isSecret: bool = False):
self.name = name
self.value = value
self.isSecret = isSecret
pass

Copilot uses AI. Check for mistakes.

DEFAULT_LIFETIME_SECONDS = 3600 * 24 # Default lifetime of 24 hours

def __init__(self, subject: str, name: str, issued_at: int | None = None, expires: int | None = None, roles: dict[str] | None = None) -> None:
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

The type annotation for the 'roles' parameter is declared as dict[str] | None, but the code and tests pass a list of role IDs. Update the type annotation to list[str] | None for consistency.

Copilot uses AI. Check for mistakes.
@simonkurtz-MSFT simonkurtz-MSFT merged commit 8c8fbf3 into main May 29, 2025
7 checks passed
@simonkurtz-MSFT simonkurtz-MSFT deleted the feature/add-authx-sample branch May 29, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Show API Authentication & Authorization with OAuth2 Json Web Token JWT

2 participants