mirror of
https://github.com/farcasclaudiu/AzureStaticWebApp-CSharp-SimpleDemo.git
synced 2026-06-22 07:01:03 +03:00
adding security
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
@page "/fetchdata"
|
||||
@inject HttpClient Http
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@attribute [Authorize]
|
||||
|
||||
<h1>Weather forecast</h1>
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
@page "/login-providers"
|
||||
|
||||
@{
|
||||
|
||||
var providers = new Dictionary<string, string[]>
|
||||
{
|
||||
{ "github", new string[3]{ "github", "github", "GitHub"}},
|
||||
{ "twitter", new string[3]{ "twitter","twitter", "Twitter" }},
|
||||
{ "microsoft", new string[3]{ "windows", "aad", "Azure AD" }}
|
||||
};
|
||||
}
|
||||
|
||||
<h1>Login</h1>
|
||||
|
||||
<div class="container">
|
||||
@foreach(var provider in providers)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-9 col-lg-6">
|
||||
<a class="btn btn-block btn-lg btn-social btn-@provider.Key" href="/.auth/login/@provider.Value[1]">
|
||||
<span class="fa fa-@provider.Value[0]"></span> Sign in with @provider.Value[2]
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
@page "/secured"
|
||||
@using Microsoft.AspNetCore.Authorization
|
||||
@inject HttpClient Http
|
||||
@attribute [Authorize(Roles = "admin")]
|
||||
|
||||
<h1>Azure Function Test</h1>
|
||||
|
||||
<h2>@result</h2>
|
||||
|
||||
|
||||
@code {
|
||||
private string result = "temp value";
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
var response = await Http.GetStringAsync("/api/secured/HelloYou?name=cloudies");
|
||||
result = response.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user