// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { #region "Add/Use - Logging - works?" loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); #endregion #region "Use - Exceptions/Errors" // TODO: read and wire up. // http://www.talkingdotnet.com/aspnet-core-diagnostics-middleware-error-handling/ //if (env.IsDevelopment()) { // app.UseDeveloperExceptionPage(); //} //else { // app.UseExceptionHandler(); //} app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); #endregion app.UseStaticFiles(); #region "Use - Swagger Documentation - BEFORE --> JWT <--" // TODO: remove in production!!! // if (env.IsDevelopment()) app.UseSwaggerDocumentation(); #endregion #region "Use - Jwt - UseAuthentication" app.UseAuthentication(); #endregion #region "Use - CORS - BEFORE --> UseMvc() <--" // https://stackoverflow.com/questions/48649878/cors-in-net-core-2-0-no-access-control-allow-origin-header-is-present-on-the // CORS middleware must precede any defined endpoints in your app that you want to support cross-origin requests(ex.before any call to UseMvc). app.UseCors("CorsPolicy"); #endregion app.UseMvc(); UAMClientLibrary.SetupClientLibrary("VisRes2", Configuration["Uam:Address"], Configuration["Uam:SAUserName"], Configuration["Uam:SAPassword"], "VisRes"); }
public async Task <JwtModel> GetTokenForUser(LoginViewModel loginModel) { var authenticateResult = await Authenticate(loginModel); if (authenticateResult.UserValidated) { // Internal users can authenticate via email address but need correct login Id loginModel.Username = authenticateResult.LoginId; UserData userData = await UAMClientLibrary.GetUserData(loginModel.Username, true); JwtModel userJwt = CreateUser(userData); // 4. Map Username to get tblUsers.UserID (if 0) if (userJwt.UserId == 0) { userJwt.UserId = await _userService.GetUserId(loginModel.Username, 0); // If UserId == 0, invalid user???? } // 5a. Add Claims Claim[] claims = _claimService.BuildClaims(userData); // Build Claims userJwt.Token = _tokenService.BuildJwtSecurityToken(userJwt, claims, _config); // Build JWT (including Claims) // 7. Save UserSession (needed for verification of token) // tblUserSessions mySession = new tblUserSessions() { UserID = userJwt.UserId, SessionAttribute = userJwt.Token }; // var sessionOkay = _sessionService.SaveSession(userJwt); return(userJwt); } else { return(new JwtModel() { }); } }
public async Task <ValidationResponse> Authenticate(LoginViewModel login) { return(await UAMClientLibrary.ValidateUser(login.Username, login.Password)); }
public async Task <ApplicationListUser> GetBasicUserData(string loginId) { List <ApplicationListUser> allUsers = await UAMClientLibrary.GetApplicationUsers(); return(allUsers.Where(c => string.Equals(c.LoginId, loginId, StringComparison.OrdinalIgnoreCase)).FirstOrDefault()); }
public async Task <UserData> GetFullUserData(string loginId, bool clearCache = false) { return(await UAMClientLibrary.GetUserData(loginId, clearCache)); }
public async Task <bool> UserHasArea(string moduleName, string areaName, string userName) { return(await UAMClientLibrary.UserHasArea(moduleName, areaName, userName)); }
public async Task <bool> UserHasAccess(string moduleName, string areaName, string accessName, string userName) { bool result = await UAMClientLibrary.UserHasAccess(moduleName, areaName, accessName, userName); return(result); }