Esempio n. 1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public static OauthAccess FromCreateFabOauthAccess(CreateFabOauthAccess pApi)
        {
            var dom = new OauthAccess();

            FromCreateFabOauthAccess(dom, pApi);
            return(dom);
        }
Esempio n. 2
0
 /*--------------------------------------------------------------------------------------------*/
 private static void FromCreateFabOauthAccess(OauthAccess pDomain, CreateFabOauthAccess pApi)
 {
     FromCreateFabVertex(pDomain, pApi);
     pDomain.Token   = pApi.Token;
     pDomain.Refresh = pApi.Refresh;
     pDomain.Expires = pApi.Expires;
 }
Esempio n. 3
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public FabOauthAccess AddAccess(IOperationContext pOpCtx, CreateOauthAccessOperation pCreateOp,
                                        long pMemberId, bool pClientMode = false)
        {
            ClearOldTokens(pOpCtx, pMemberId);

            const int expireSec      = 3600;
            bool      needsActiveMem = (pOpCtx.Auth.ActiveMemberId == null);

            CreateFabOauthAccess coa = new CreateFabOauthAccess();

            coa.Token   = pOpCtx.Code32;
            coa.Refresh = (pClientMode ? null : pOpCtx.Code32);
            coa.Expires = pOpCtx.UtcNow.AddSeconds(expireSec).Ticks;
            coa.AuthenticatesMemberId = pMemberId;

            if (needsActiveMem)
            {
                pOpCtx.Auth.SetFabricActiveMember();
            }

            OauthAccess result = pCreateOp.Execute(pOpCtx,
                                                   new CreateOperationBuilder(), new CreateOperationTasks(), coa);

            if (needsActiveMem)
            {
                pOpCtx.Auth.RemoveFabricActiveMember();
            }

            return(new FabOauthAccess {
                AccessToken = result.Token,
                RefreshToken = result.Refresh,
                ExpiresIn = expireSec,
                TokenType = "bearer"
            });
        }
Esempio n. 4
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        protected override void TestSetUp()
        {
            base.TestSetUp();

            vCreateOauthAccess = new CreateFabOauthAccess();
            vCreateOauthAccess.AuthenticatesMemberId = (long)SetupMemberId.FabZach;
            vCreateOauthAccess.Expires = 92387523598;
            vCreateOauthAccess.Refresh = "12345678901234567890123456789012";
            vCreateOauthAccess.Token   = "abcd5678901234567890123456789XYZ";
        }
Esempio n. 5
0
        /*--------------------------------------------------------------------------------------------*/
        public virtual void AddOauthAccessAuthenticatesMember(ICreateOperationBuilder pCreCtx,
                                                              OauthAccess pNewDom, CreateFabOauthAccess pNewCre, IWeaverVarAlias <OauthAccess> pAlias)
        {
            var a = AddEdge <OauthAccess, OauthAccessAuthenticatesMember, Member>(
                pCreCtx, pAlias, pNewCre.AuthenticatesMemberId);

            var maboaEdge = new MemberAuthenticatedByOauthAccess();

            maboaEdge.Timestamp = pNewDom.Timestamp;

            AddReverseEdge(pCreCtx, a, maboaEdge, pAlias);
        }
Esempio n. 6
0
        public void AddOauthAccessAuthenticatesMember()
        {
            var dom = new OauthAccess {
                Timestamp = 9439439349
            };

            var cre = new CreateFabOauthAccess {
                AuthenticatesMemberId = 7272727
            };

            TestAddEdge(
                x => vTasks.AddOauthAccessAuthenticatesMember(
                    x, dom, cre, GetAddVertexAlias <OauthAccess>()),
                cre.AuthenticatesMemberId,
                DbName.Edge.OauthAccessAuthenticatesMemberName,
                DbName.Edge.MemberAuthenticatedByOauthAccessName,
                new[] {
                DbName.Edge.MemberAuthenticatedByOauthAccess.Timestamp
            },
                new object[] {
                dom.Timestamp
            }
                );
        }
Esempio n. 7
0
 ////////////////////////////////////////////////////////////////////////////////////////////////
 /*--------------------------------------------------------------------------------------------*/
 public CreateFabOauthAccessValidator(CreateFabOauthAccess pCreateObj) : base(pCreateObj)
 {
     vCreateObj = pCreateObj;
 }