A Flask-based testing application that demonstrates OIDC authentication with the iSHARE DMI ecosystem using JWE-encrypted JWT tokens.
This application implements the iSHARE OIDC authentication flow using:
- OIDC Authorization Code Flow with PKCE for secure authentication
- JWE-encrypted JWT tokens instead of traditional client_id/client_secret
- iSHARE-compliant JWT creation using the python-ishare library
- Browser-based authentication flow for proper cookie handling
Please note that the application only implements the OIDC flow and does not implement the lookup of parties in an iSHARE Satellite (which would usually be part of an iSHARE implementation).
- ✅ iSHARE-compliant JWT token creation and JWE encryption
- ✅ OIDC authorization code flow with PKCE
- ✅ Browser-based authentication with proper session management
- ✅ User profile display with token information
- ✅ Optimized session storage (minimal cookie size)
- ✅ Error handling and user feedback
- Python 3.8+
- iSHARE client certificates (private key and certificate chain)
- A registration with an iSHARE Participant Registry in an iSHARE network (UAT, PRD)
- Registration with an iSHARE Identity Provider (IdP)
- Optionally (check with IdP) registration for the data space
-
Clone the repository:
git clone <repository-url> cd python-ishare-idp-client
-
Install dependencies:
pip install -r requirements.txt
-
Configure environment variables:
cp env.example .env # Edit .env with your iSHARE configuration -
Place your iSHARE certificates:
pki/ ├── your-client-private-key.pem └── your-client-certificate.pem
Modify the .env file to configure the environment variables.
-
Start the application:
python app.py
-
Access the application: Open your browser and navigate to
http://localhost:5000 -
Test the authentication flow:
- Click "Login with iSHARE" to initiate authentication
- Complete the authentication on the iSHARE provider
- View your profile and token information
app.py- Flask application with routes and session managementoidc_client.py- OIDC client handling authentication flowishare_jwt.py- iSHARE JWT creation and JWE encryptionconfig.py- Application configurationtemplates/- HTML templates for the web interface
- Authorization Request: Browser submits POST request with JWE-encrypted JWT
- User Authentication: User authenticates with iSHARE provider
- Authorization Code: Provider redirects back with authorization code
- Token Exchange: Application exchanges code for access/ID tokens
- User Info: Application retrieves user information
- Session Management: User data stored in optimized session
- PKCE (Proof Key for Code Exchange) for secure authorization
- State parameter for CSRF protection
- Nonce for replay attack prevention
- JWE encryption for secure token transmission
- Session optimization to prevent cookie size issues
GET /- Home pageGET /login- Initiate authenticationGET /callback- Handle authentication callbackGET /profile- User profile pageGET /logout- Logout and redirect to providerGET /api/user- API endpoint for user informationGET /api/refresh- Token refresh endpoint (disabled)
python-ishare-idp-client/
├── app.py # Flask application
├── config.py # Configuration settings
├── oidc_client.py # OIDC client implementation
├── ishare_jwt.py # iSHARE JWT/JWE handling
├── requirements.txt # Python dependencies
├── env.example # Environment variables template
├── pki/ # iSHARE certificates directory
├── templates/ # HTML templates
│ ├── base.html
│ ├── index.html
│ ├── profile.html
│ └── error.html
└── README.md
- Flask - Web framework
- python-ishare - iSHARE JWT creation
- jwcrypto - JWE encryption/decryption
- PyJWT - JWT handling
- cryptography - PKI operations
- requests - HTTP client
- Certificate not found: Ensure your iSHARE certificates are in the
pki/directory - Invalid issuer: Verify the
OIDC_ISSUERmatches your provider configuration - Cookie too large: The application optimizes session storage automatically
- Authentication failed: Check your iSHARE client configuration and certificates
The application runs in debug mode by default. Check the console output for detailed error information.
This project is for testing purposes only. Ensure compliance with iSHARE specifications and your organization's security policies.
For issues related to:
- iSHARE specifications: Consult the official iSHARE documentation on https://framework.ishare.eu and https://dev.ishare.eu
- Implement logout