コード例 #1
0
        public IHttpActionResult Options(Nullable <Guid> Id = default(Nullable <Guid>))
        {
            var post1 = new Resources.Session
            {
                Id = Guid.NewGuid(),
            };
            var response = new BlackBarLabs.Api.Resources.Options
            {
                Post = new[] { post1 },
            };

            if (default(Nullable <Guid>) != Id)
            {
                var authId   = Guid.NewGuid();
                var jwtToken = BlackBarLabs.Security.Tokens.JwtTools.CreateToken(
                    Id.Value, authId, new Uri("http://example.com"), TimeSpan.FromDays(200000),
                    (token) => token,
                    (config) => string.Empty,
                    (config, why) => string.Empty);

                var put1 = new Resources.Session
                {
                    Id = Id.Value,
                    AuthorizationId = authId,
                };
                response.Put = new[] { put1 };
            }
            return(Json(response));
        }
        public static Task <HttpResponseMessage> CredentialOptionsAsync(this HttpRequestMessage request)
        {
            var credentialProviders = new Resources.PasswordCredential[]
            {
                new Resources.PasswordCredential
                {
                    UserId = "0123456789",
                    Token  = "ABC.123.MXC",
                },
                new Resources.PasswordCredential
                {
                    //Method = CredentialValidationMethodTypes.OpenIdConnect,
                    //Provider = new Uri("urn:auth.gibbits.nc2media.com/AuthOpenIdConnect/"),
                    UserId = Guid.NewGuid().ToString("N"),
                    Token  = "EDF.123.A3EF",
                },
                new Resources.PasswordCredential
                {
                    //Method = CredentialValidationMethodTypes.Implicit,
                    //Provider = new Uri("http://www.example.com/ImplicitAuth"),
                    UserId = Guid.NewGuid().ToString("N"),
                    Token  = Guid.NewGuid().ToString("N"),
                }
            };
            var response = new BlackBarLabs.Api.Resources.Options()
            {
                Get = credentialProviders,
            };

            var responseMessage = request.CreateResponse(System.Net.HttpStatusCode.OK, response);

            return(responseMessage.ToTask());
        }