/// <summary> /// Show username and token stored in database /// </summary> /// <returns></returns> public JsonResult ShowAuthenticationValues() { JsonResult json = null; using (var googleService = _authorize.Authorize()) { json = Json(_authorize.ResponseCredentials(), JsonRequestBehavior.AllowGet); } return(json); }
public string GetInformation(string name, string pass) { if (authorize.Authorize(name, pass)) { return("Secret information"); } return("Not authorized"); }
public bool HasAccess( string path, string username, string[] roles, AccessType type) { return(_authorize?.Authorize(path, username, roles, type) ?? true); }
static void Main(string[] args) { IKernel kernel = new StandardKernel(); kernel.Bind <IAuthorize>().To <FacebookAuthenticationProvider>(); kernel.Bind <IDbConnection>().To <DbConnection>(); IAuthorize authorize = kernel.Get <IAuthorize>(); var isAuthorized = authorize.Authorize("mojLogin", "mojeHaslo"); }
public ActionResult LogOn(LogOnViewModel logOn) { if (authentication.Authorize(logOn.Username, logOn.Password)) { return(Redirect(logOn.ReturnUrl)); } else { ModelState.AddModelError("", "Invalid credentials."); } return(View()); }
public async Task <TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <TResponse> next) { if (!await _authorize.Authorize(request)) { _logger.LogWarning("User is not authorized {user}", request.User?.GetIdentity()); return(Result.Forbidden.ConvertTo <TResponse>()); } var response = await next(); return(response); }
protected virtual bool Authorize() { if (IsPostBack) { return(true); } bool hasAccess = false; bool hasAttr = false; foreach (object at in GetType().GetCustomAttributes(true)) { IAuthorize auth = at as IAuthorize; if (auth != null) { hasAttr = true; if (auth.Authorize(this.Context)) { hasAccess = true; } } } if (hasAccess) { return(true); } if (!hasAttr) { string sitmap = HttpContext.Current.Server.MapPath("~/Web.sitemap"); if (File.Exists(sitmap)) { XmlDocument doc = new XmlDocument(); doc.Load(sitmap); foreach (XmlNode childNode in doc.DocumentElement.FirstChild.ChildNodes) { if (childNode.NodeType == XmlNodeType.Comment) { continue; } if (FindNodeAndCheckAccess(childNode, "Menu", false)) { return(true); } } } } FormsAuthentication.RedirectToLoginPage(); return(false); }