Esempio n. 1
0
        /*--------------------------------------------------------------------------------------------*/
        private OauthMember GetOauthMember(IOperationData pData, Member pMemPath, string pName)
        {
            IWeaverVarAlias <Member> memAlias;
            IWeaverQuery             memQ = pMemPath.ToQueryAsVar("m", out memAlias);

            IWeaverQuery appQ = Weave.Inst.FromVar(memAlias)
                                .DefinedByApp.ToApp
                                .Property(x => x.VertexId)
                                .ToQuery();

            IDataAccess acc = pData.Build(null, true);

            acc.AddSessionStart();
            acc.AddQuery(memQ, true);
            acc.AppendScriptToLatestCommand("(m?m=m.next():null);");
            string memCmdId = acc.GetLatestCommandId();

            acc.AddQuery(appQ, true);
            acc.AddConditionsToLatestCommand(memCmdId);
            acc.AddSessionClose();

            IDataResult res = acc.Execute("OauthAccess-" + pName);

            if (res.GetCommandResultCount(1) == 0)
            {
                return(null);
            }

            var om = new OauthMember();

            om.Member = res.ToElementAt <Member>(1, 0);
            om.AppId  = res.ToLongAt(2, 0);
            return(om);
        }
Esempio n. 2
0
        /*--------------------------------------------------------------------------------------------*/
        private FabOauthAccess ExecuteRt(string pRefresh, string pSecret, string pRedirUri)
        {
            Validate(pSecret, pRedirUri);

            if (string.IsNullOrEmpty(pRefresh))
            {
                throw vTasks.NewFault(AccessErrors.invalid_request, AccessErrorDescs.NoRefresh);
            }

            OauthMember om = vTasks.GetMemberByRefresh(vOpCtx.Data, pRefresh);

            if (om == null)
            {
                throw vTasks.NewFault(AccessErrors.invalid_request, AccessErrorDescs.BadRefresh);
            }

            vTasks.GetApp(vOpCtx.Data, om.AppId, pSecret);
            return(vTasks.AddAccess(vOpCtx, new CreateOauthAccessOperation(), om.Member.VertexId));
        }
Esempio n. 3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        private FabOauthAccess ExecuteAc(string pCode, string pSecret, string pRedirUri)
        {
            Validate(pSecret, pRedirUri);

            if (string.IsNullOrEmpty(pCode))
            {
                throw vTasks.NewFault(AccessErrors.invalid_request, AccessErrorDescs.NoCode);
            }

            OauthMember om = vTasks.GetMemberByGrant(vOpCtx.Data, pCode);

            if (om == null)
            {
                throw vTasks.NewFault(AccessErrors.invalid_grant, AccessErrorDescs.BadCode);
            }

            if (pRedirUri.ToLower() != om.Member.OauthGrantRedirectUri)
            {
                throw vTasks.NewFault(AccessErrors.invalid_grant, AccessErrorDescs.RedirMismatch);
            }

            vTasks.GetApp(vOpCtx.Data, om.AppId, pSecret);
            return(vTasks.AddAccess(vOpCtx, new CreateOauthAccessOperation(), om.Member.VertexId));
        }