Skip to content

Visapick-Team/IAM-SDK

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Iam python SDK

IAM is a proprietary package made by VisaPick group to enterprice purposes.

Installation

  • Just run pip install git+https://github.com/Visapick-Team/IAM-SDK@main

FastAPI Example

Dependency

from iam.validation import Authorize
from iam.schema import TokenPayload

@router.get('/admin/{uuid}')
def function(
        uuid: str,
        user: TokenPayload = Depends(Authorize(
            roles=['admin'], scopes=["product:object:get"]))
    ):
    ...

Django Example

ModelViewSet or GenericViewSet

from rest_framework.viewsets import ModelViewSet
from iam.permissions import AutoScopePermission


class SampleScopePermission(AutoScopePermission):
    _service_name = "service"

class MyModelViewSet(ModelViewSet):
    permission_classes = [SampleScopePermission]
    queryset = MyModel.objects.all()
    serializer_class = MyModelSerializer
    object_name = "sample"

This will validate below scopes for all actions in the MyModelViewSet.

service:sample:get
service:sample:list
service:sample:create
service:sample:update
service:sample:delete

if you are using custom actions, the permission class can handle your action and will check like this

service:sample:custom_action

Function-Base APIView

from rest_framework.decorators import api_view
from iam.permissions import scope_permission


@api_view(['DELETE'])
@scope_permission(":profile:delete")
def SampleFunctionAPIView(request):
    return Response({"message": "Herkese selam"})

Contributors

Mohammadreza (Maintainer)

About

A python SDK to validate and verify JWT tokens

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages