You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Наиль Ибрагимов 6642d07cec Merge pull request 'Fix retrieving redis version' (#2) from fix-storage into master 11 months ago
grpc_sso_client Fix retrieving redis version 11 months ago
tests Added sso gRPC client 11 months ago
.gitignore Added sso gRPC client 11 months ago
Pipfile Added sso gRPC client 11 months ago
README.md Added sso gRPC client 11 months ago
setup.py Added sso gRPC client 11 months ago

README.md

gRPC-sso-client

Installation

$ pipenv install -e git+https://git.brandquad.ru/common/grpc-sso-client

Server example

import grpc
import redis
from decouple import config
from grpc_sso_client import JwtServerInterceptor, RedisJWTStorage
from redis import Redis


redis_client = Redis.from_url(config('REDIS_URL'))

interceptor = JwtServerInterceptor(
    host=config('SSO_URL'),
    access_token=config('SSO_ACCESS_TOKEN'),
    access_key=config('SSO_ACCESS_KEY'),
    issuer='issuer',
    storage=RedisJWTStorage(redis_client)
)

server = grpc.server(
    futures.ThreadPoolExecutor(max_workers=max_workers),
    interceptors=[interceptor]
)

# ADD YOUR SERVICER HERE

server.add_insecure_port('localhost:6666')
server.start()
server.wait_for_termination()

Client example

import grpc
import redis
from grpc_sso_client import JwtClientInterceptor
from redis import Redis


redis_client = Redis.from_url(config('REDIS_URL'))

interceptor = JwtClientInterceptor(
    host=config('SSO_URL'),
    access_token=config('SSO_ACCESS_TOKEN'),
    access_key=config('SSO_ACCESS_KEY'),
    issuer='issuer',
    storage=RedisJWTStorage(redis_client),
    payload={'account': 'UNI'}
)
with grpc.insecure_channel("localhost:6666") as channel:
    channel = grpc.intercept_channel(channel, interceptor)
    ...