Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Plugins have a base WebViewPage to inherit, this offers integration with various Disco services. Plugins can also add Authorization attributes to their Web Handlers and Controller Methods.
- Loading branch information
Showing
21 changed files
with
496 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
Disco.Services/Authorization/DiscoAuthorizeBaseAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Disco.Services.Users; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Web.Mvc; | ||
|
||
namespace Disco.Services.Authorization | ||
{ | ||
public abstract class DiscoAuthorizeBaseAttribute : AuthorizeAttribute | ||
{ | ||
protected AuthorizationToken Token | ||
{ | ||
get | ||
{ | ||
return UserService.CurrentAuthorization; | ||
} | ||
} | ||
|
||
public abstract bool IsAuthorized(System.Web.HttpContextBase httpContext); | ||
public abstract string HandleUnauthorizedMessage(); | ||
|
||
protected sealed override bool AuthorizeCore(System.Web.HttpContextBase httpContext) | ||
{ | ||
if (httpContext == null) | ||
throw new ArgumentNullException("httpContext"); | ||
|
||
return IsAuthorized(httpContext); | ||
} | ||
|
||
protected sealed override void HandleUnauthorizedRequest(AuthorizationContext filterContext) | ||
{ | ||
string resultMessage = HandleUnauthorizedMessage(); | ||
|
||
filterContext.Result = new HttpUnauthorizedResult(resultMessage); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.