public async Task <JsonResult> RequstToken(AuthenticationInputModel input) { //TODO 更新登录IP跟时间 // discover endpoints from metadata var client = new HttpClient(); var disco = await client.GetDiscoveryDocumentAsync("http://localhost:5000"); if (disco.IsError) { return(Json(disco.Error)); } // request token var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest { Address = disco.TokenEndpoint, UserName = input.UserName, //"admin", Password = MD5Encrypt.EncryptBy32(input.Password), // "95ec2e295d99fa60fbb1e245175a25", ClientId = "client2", ClientSecret = "secret", }); AuthenticationOutputMessageModel model = new AuthenticationOutputMessageModel(); if (tokenResponse.IsError) { model.Code = 50008; model.Message = tokenResponse.Error; return(Json(model)); } model.Code = 20000; model.Data = tokenResponse; return(Json(model)); }
public AuthenticationResultModel Authenticate(AuthenticationInputModel input) { var outputModel = new AuthenticationResultModel { Input = input }; var operation = _authentications.FirstOrDefault(a => a.Metadata.AuthenticationType == input.TypeString); outputModel.Result = operation == null ? "Implementation cannot be found" : operation.Value.Authenticate(input.Username, input.Password); return(outputModel); }
public AuthenticationViewModel GetAuthenticationInfo(AuthenticationInputModel inputModel) { return(_userPresentationService.GetAuthenticationViewModel(inputModel)); }