Metadata-Version: 2.1
Name: ft_jwt
Version: 0.1.0
Summary: A Python implementation of JSON Web Tokens (JWT) for authentication and authorization using a symmetric secret key and HMAC-SHA256.
Home-page: https://github.com/minthe/ft_transcendence/blob/main/auth/ft_jwt/ft_jwt/ft_jwt.py
Author: vfuhlenb
Author-email: minh.tee@gmail.com
License: UNKNOWN
Description: # JWT Authentication
        
        A Python implementation of JSON Web Tokens (JWT) for authentication and authorization using a symmetric secret key and HMAC-SHA256.
        
        ## Changelog
        
        ### 0.1.00
          - does not return the 'user_id' as additional argument anymore.
          - 'user_id' is now added to the request object.
          - changed 404 to 401 if token is missing and updated response messages.
        ### 0.0.20
          - returns JsonResponse with {'message': "string"} and the status-code
        
        ## Features
        
        - Generate JWT tokens with customizable expiration times
        - Validate JWT tokens and verify their integrity using a symmetric secret key and HMAC-SHA256
        - Extract user information (such as user ID 'sub') from JWT tokens
        
        ## Installation
        
        You can install the package via pip:
        
        ```pip install ft_jwt```
        
        ## Usage
        
        ```python
        from ft_jwt.ft_jwt import FT_JWT
        
        # Create a JWT instance with your secret key
        
        secret_key = 'your_secret_key'
        ftjwt = FT_JWT(secret_key)
        
        # Generate a token for a user
        
        sub = '1'
        token = jwt.createToken(sub)
        
        # Validate a token
        
        is_valid, message = ftjwt.validateToken(token)
        if is_valid:
            print('Token is valid')
        else:
            print(f'Token is invalid: {message}')
        
        # Get the user ID from a token
        
        user_id = ftjwt.getUserId(token)
        print(f'User ID: {sub}')
        
        # Use the decorator to validate against a JWT for a protected route
        
        @ftjwt.token_required
        def protected_route():
            # This function will be executed only if the token is valid
            # ...
        ```
        
        # Contributing
        Contributions are welcome! Please open an issue or submit a pull request.
        
        # License
        This project is licensed under the MIT License.
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
