diff options
author | crupest <crupest@outlook.com> | 2019-02-07 00:39:51 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2019-02-07 00:39:51 +0800 |
commit | 4262a25addf26705e4c5ab07acafd3eb8702fa4b (patch) | |
tree | d39469b839a1ef31bcb0b3afdeb0ae351bf63bd0 /Timeline/Controllers/TestController.cs | |
parent | 167deab9648f2f2fc7f69b9eeee03f0d18be3c50 (diff) | |
download | timeline-4262a25addf26705e4c5ab07acafd3eb8702fa4b.tar.gz timeline-4262a25addf26705e4c5ab07acafd3eb8702fa4b.tar.bz2 timeline-4262a25addf26705e4c5ab07acafd3eb8702fa4b.zip |
Add authorization.
Diffstat (limited to 'Timeline/Controllers/TestController.cs')
-rw-r--r-- | Timeline/Controllers/TestController.cs | 34 |
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"; + } + } +} |