コード例 #1
0
ファイル: SteamLoginHandler.cs プロジェクト: Nuterra/YinYang
        private static LightOpenID InitializeOpenID(IOwinContext request)
        {
            var openID = new LightOpenID(request.Request);

            openID.Realm     = new Uri(request.Request.Uri.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped));
            openID.ReturnUrl = new Uri(openID.Realm, "/login/landing");
            return(openID);
        }
コード例 #2
0
ファイル: SteamLoginHandler.cs プロジェクト: Nuterra/YinYang
        public async Task HandleRequestAsync(IOwinContext request)
        {
            LightOpenID openID = InitializeOpenID(request);

            switch (request.Request.Uri.AbsolutePath)
            {
            case "/login":
                await AuthenticationRedirect(request, openID);

                break;

            case "/login/landing":
                await HandleLanding(request, openID);

                break;
            }
        }
コード例 #3
0
ファイル: SteamLoginHandler.cs プロジェクト: Nuterra/YinYang
        private async Task HandleLanding(IOwinContext request, LightOpenID openID)
        {
            bool valid = await openID.Validate();

            if (!valid)
            {
                request.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                await request.Response.WriteAsync(FailureMessage);

                return;
            }

            if (openID.ClaimedID == null || !openID.ClaimedID.StartsWith(SteamClaimNamespace))
            {
                request.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                await request.Response.WriteAsync(FailureMessage);

                return;
            }

            long steamID64;

            if (!long.TryParse(openID.ClaimedID.Substring(SteamClaimNamespace.Length), out steamID64))
            {
                request.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                await request.Response.WriteAsync(FailureMessage);

                return;
            }

            var steamID = new SteamID(steamID64);

            if (!steamID.IsValid())
            {
                request.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                await request.Response.WriteAsync(FailureMessage);

                return;
            }

            await HandleValidLogin(request, steamID);
        }
コード例 #4
0
ファイル: SteamLoginHandler.cs プロジェクト: Nuterra/YinYang
        private static async Task AuthenticationRedirect(IOwinContext request, LightOpenID openID)
        {
            string s = await openID.GetAuthUrl("http://steamcommunity.com/openid/");

            request.Response.Redirect(s);
        }