aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Controllers/TestController.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2019-02-07 00:39:51 +0800
committercrupest <crupest@outlook.com>2019-02-07 00:39:51 +0800
commit101631a0041f22570d7c2d9378cbfd0cec5ca14b (patch)
tree93a50ac104e1f590f9d7aa3d8f0e140a0992035d /Timeline/Controllers/TestController.cs
parent478dfefdbf4b118d7453673a3aa93a638586b850 (diff)
downloadtimeline-101631a0041f22570d7c2d9378cbfd0cec5ca14b.tar.gz
timeline-101631a0041f22570d7c2d9378cbfd0cec5ca14b.tar.bz2
timeline-101631a0041f22570d7c2d9378cbfd0cec5ca14b.zip
Add authorization.
Diffstat (limited to 'Timeline/Controllers/TestController.cs')
-rw-r--r--Timeline/Controllers/TestController.cs34
1 files changed, 34 insertions, 0 deletions
diff --git a/Timeline/Controllers/TestController.cs b/Timeline/Controllers/TestController.cs
new file mode 100644
index 00000000..1563830c
--- /dev/null
+++ b/Timeline/Controllers/TestController.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+
+namespace Timeline.Controllers
+{
+ [Route("api/[controller]")]
+ public class TestController : Controller
+ {
+ [HttpGet("[action]")]
+ [Authorize]
+ public string Action1()
+ {
+ return "test";
+ }
+
+ [HttpGet("[action]")]
+ [Authorize(Roles = "User,Admin")]
+ public string Action2()
+ {
+ return "test";
+ }
+
+ [HttpGet("[action]")]
+ [Authorize(Roles = "Admin")]
+ public string Action3()
+ {
+ return "test";
+ }
+ }
+}