/// <summary> /// Allows a direct login if and only if: /// * Scheme is "Guest" /// * The payload is valid /// * The payload's token is neither null or whitespaces /// </summary> /// <param name="ctx">The current context.</param> /// <param name="monitor">The monitor to use.</param> /// <param name="scheme">The authentication scheme.</param> /// <param name="payload">The login payload.</param> /// <returns></returns> public Task <bool> AllowAsync(HttpContext ctx, IActivityMonitor monitor, string scheme, object payload) { using (monitor.OpenInfo($"{GetType()}.AllowAsync challenge")) { if (scheme != "Guest") { monitor.Trace("Invalid scheme"); return(Task.FromResult(false)); } monitor.Trace("Valid scheme"); IGuestActorInfo info; try { info = _infoFactory.ExtractPayload(payload); } catch (Exception exception) { monitor.Error("Error while extracting payload.", exception); return(Task.FromResult(false)); } Debug.Assert(info != null); if (string.IsNullOrWhiteSpace(info.Token)) { monitor.Trace("Invalid payload"); return(Task.FromResult(false)); } monitor.Trace("Valid payload"); monitor.Info("DirectLogin allowed."); return(Task.FromResult(true)); } }
UCLResult IGenericAuthenticationProvider.CreateOrUpdateUser(ISqlCallContext ctx, int actorId, int userId, object payload, UCLMode mode) { IUserOidcInfo info = _infoFactory.ExtractPayload(payload); return(CreateOrUpdateOidcUser(ctx, actorId, userId, info, mode)); }
UCLResult IGenericAuthenticationProvider.CreateOrUpdateUser(ISqlCallContext ctx, int actorId, int userId, object payload, UCLMode mode) => CreateOrUpdateGuestActor(ctx, actorId, userId, _infoFactory.ExtractPayload(payload), mode);