Ejemplo n.º 1
0
def socket_print_debug(message):
    print('======= PRINT DEBUG =========')
    print(f'request_has_sid: {request.sid}')
    client = scman.by_sid(request.sid)
    print('client info:')
    print(f'sid: {client.sid}')
    print(f'quuid: {client.quuid}')
    print(f'openId: {client.openId}')
    print('====end print debug. client says "{message}"')
Ejemplo n.º 2
0
def authorize_sso():
    client = OAuth2Session(
        conf['client_id'],
        redirect_uri=build_redirect_uri(),
        state=session['oauth_state'])

    token_dict = client.fetch_token(
        conf['access_token_url'],
        client_secret=conf['client_secret'],
        authorization_response=request.url)
    print(token_dict)

    client = scman.by_sid(session['sid'])
    client.sso_access_token = token_dict['access_token']
    # when the client receives this event it will call get_my_client_info
    client.private_emit('sso_signin_successful')

    # oauth_state is a CSRF token and sid will eventually be stale; remove them
    # so they aren't accidentally used in the future
    del session['oauth_state']
    del session['sid']

    return 'You are signed in - closing window.<script>window.close()</script>'
Ejemplo n.º 3
0
def authorize_sso():
    client = OAuth2Session(conf['client_id'],
                           redirect_uri=build_redirect_uri(),
                           state=session['oauth_state'])

    # token_dict returns the access token used for future requests, a refresh
    # token, client_id which is a JWT
    token_dict = client.fetch_token(conf['access_token_url'],
                                    client_secret=conf['client_secret'],
                                    authorization_response=request.url)

    sclient = scman.by_sid(session['sid'])
    sclient.sso_access_token = token_dict['access_token']
    sclient.get_openid_info()
    # emitting this event to the client  will initiate get_my_client_info
    sclient.private_emit(Semit.sso_signin_successful)

    # oauth_state is a CSRF token and sid will eventually be stale; remove them
    # so they aren't accidentally used in the future
    del session['oauth_state']
    del session['sid']

    return 'You are signed in - this window will close automatically. \
Ejemplo n.º 4
0
def socket_sso_signin():
    print('signing in')
    client = scman.by_sid(request.sid)
    client.private_emit('open_sso_signin_window',
                        {'ssoUrl': build_sso_uri(request.sid)})
Ejemplo n.º 5
0
def get_my_client_info(client_sjwt):
    scman.on_client_connect_handler(request.sid, client_sjwt)
    client = scman.by_sid(request.sid)
    client.send_client_info()
Ejemplo n.º 6
0
def socket_sso_signout():
    client = scman.by_sid(request.sid)
    scman.remove_client(client)
    client.private_emit(Semit.open_window, {'url': conf['logout_url']})
Ejemplo n.º 7
0
def socket_sso_signin():
    client = scman.by_sid(request.sid)
    client.private_emit(Semit.open_window, {'url': build_sso_uri(request.sid)})
Ejemplo n.º 8
0
def get_my_client_info():
    client = scman.by_sid(request.sid)
    client.send_client_info()
    print('client info sent')
    print(client.quuid)
    print(client.auth_status)