本文整理汇总了C#中IdentityServer3.Core.Models.SignInMessage类的典型用法代码示例。如果您正苦于以下问题:C# SignInMessage类的具体用法?C# SignInMessage怎么用?C# SignInMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SignInMessage类属于IdentityServer3.Core.Models命名空间,在下文中一共展示了SignInMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginActionResult
public LoginActionResult(IViewService viewSvc, LoginViewModel model, SignInMessage message)
: base(async () => await viewSvc.Login(model, message))
{
if (viewSvc == null) throw new ArgumentNullException("viewSvc");
if (model == null) throw new ArgumentNullException("model");
if (message == null) throw new ArgumentNullException("message");
}
示例2: ValidateAsync
public async Task<CustomGrantValidationResult> ValidateAsync(ValidatedTokenRequest request)
{
var legacyAccountStoreType = request.Raw.Get("account_store");
var id = request.Raw.Get("legacy_id");
var secret = request.Raw.Get("legacy_secret");
if (string.IsNullOrWhiteSpace(legacyAccountStoreType) ||
string.IsNullOrWhiteSpace(id) ||
string.IsNullOrWhiteSpace(secret))
{
Logger.Error("malformed request");
return null;
}
var message = new SignInMessage { Tenant = legacyAccountStoreType };
var context = new LocalAuthenticationContext
{
UserName = id, Password = secret,
SignInMessage = message
};
await _users.AuthenticateLocalAsync(context);
var result = context.AuthenticateResult;
if (result.IsError)
{
Logger.Error("authentication failed");
return new CustomGrantValidationResult("Authentication failed.");
}
return new CustomGrantValidationResult(
result.User.GetSubjectId(),
"custom",
result.User.Claims);
}
示例3: Login
/// <summary>
/// Gets the currently running client app to put it's name in the login page
/// </summary>
/// <param name="model"></param>
/// <param name="message"></param>
/// <returns></returns>
public async Task<Stream> Login(LoginViewModel model, SignInMessage message)
{
var client = await clientStore.FindClientByIdAsync(message.ClientId);
var name = client != null ? client.ClientName : null;
return await Render(model, "login", name);
}
示例4: AuthorizeInteractionResponseGenerator
public AuthorizeInteractionResponseGenerator(IdentityServerOptions options, IConsentService consent, IUserService users, ILocalizationService localizationService)
{
_signIn = new SignInMessage();
_options = options;
_consent = consent;
_users = users;
_localizationService = localizationService;
}
示例5: LoginResult
public LoginResult(IDictionary<string, object> env, SignInMessage message)
{
if (env == null) throw new ArgumentNullException("env");
if (message == null) throw new ArgumentNullException("message");
this.env = env;
this.message = message;
}
示例6: GetLoginPage
private HttpResponseMessage GetLoginPage(SignInMessage msg = null)
{
msg = msg ?? new SignInMessage() { ReturnUrl = Url("authorize") };
if (msg.ClientId == null) msg.ClientId = TestClients.Get().First().ClientId;
SignInId = WriteMessageToCookie(msg);
var resp = Get(Constants.RoutePaths.Login + "?signin=" + SignInId);
ProcessXsrf(resp);
return resp;
}
示例7: Login
void Login(bool setCookie = true)
{
var msg = new SignInMessage() { ReturnUrl = Url("authorize") };
var signInId = WriteMessageToCookie(msg);
var url = Constants.RoutePaths.Login + "?signin=" + signInId;
var resp = Get(url);
ProcessXsrf(resp);
if (setCookie)
{
resp = PostForm(url, new LoginCredentials { Username = "alice", Password = "alice" });
client.SetCookies(resp.GetCookies());
}
}
示例8: IsLocalLoginAllowedForClient
async Task<bool> IsLocalLoginAllowedForClient(SignInMessage message)
{
if (message != null && message.ClientId.IsPresent())
{
var client = await clientStore.FindClientByIdAsync(message.ClientId);
if (client != null)
{
return client.EnableLocalLogin;
}
}
return true;
}
示例9: GetRedirectUrl
private Uri GetRedirectUrl(SignInMessage signInMessage, AuthenticateResult authResult)
{
if (signInMessage == null) throw new ArgumentNullException("signInMessage");
if (authResult == null) throw new ArgumentNullException("authResult");
if (authResult.IsPartialSignIn)
{
var path = authResult.PartialSignInRedirectPath;
if (path.StartsWith("~/"))
{
path = path.Substring(2);
path = Request.GetIdentityServerBaseUrl() + path;
}
var host = new Uri(context.GetIdentityServerHost());
return new Uri(host, path);
}
else
{
return new Uri(signInMessage.ReturnUrl);
}
}
示例10: Login
public async Task<Stream> Login (LoginViewModel model, SignInMessage message)
{
return await Render (model, "Login");
}
示例11: RedirectToLogin
IHttpActionResult RedirectToLogin(SignInValidationResult result)
{
Uri publicRequestUri = GetPublicRequestUri();
var message = new SignInMessage();
message.ReturnUrl = publicRequestUri.ToString();
if (!String.IsNullOrWhiteSpace(result.HomeRealm))
{
message.IdP = result.HomeRealm;
}
if (!String.IsNullOrWhiteSpace(result.Federation))
{
message.AcrValues = new[] { result.Federation };
}
var env = Request.GetOwinEnvironment();
var url = env.CreateSignInRequest(message);
return Redirect(url);
}
示例12: RaiseSuccessfulResourceOwnerAuthenticationEventAsync
private async Task RaiseSuccessfulResourceOwnerAuthenticationEventAsync(string userName, string subjectId, SignInMessage signInMessage)
{
await _events.RaiseSuccessfulResourceOwnerFlowAuthenticationEventAsync(userName, subjectId, signInMessage);
}
示例13: Login
/// <summary>
/// Loads the HTML for the login page.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="message">The message.</param>
/// <returns>
/// Stream for the HTML
/// </returns>
public virtual Task<Stream> Login(LoginViewModel model, SignInMessage message)
{
return Render(model, LoginView);
}
示例14: LoginExternalCallback_UserIsAnonymous_NoSubjectIsPassedToUserService
public void LoginExternalCallback_UserIsAnonymous_NoSubjectIsPassedToUserService()
{
var msg = new SignInMessage();
msg.IdP = "Google";
msg.ReturnUrl = Url("authorize");
var resp1 = GetLoginPage(msg);
var sub = new Claim(Constants.ClaimTypes.Subject, "123", ClaimValueTypes.String, "Google");
SignInIdentity = new ClaimsIdentity(new Claim[] { sub }, Constants.ExternalAuthenticationType);
var resp2 = client.GetAsync(resp1.Headers.Location.AbsoluteUri).Result;
client.SetCookies(resp2.GetCookies());
Get(Constants.RoutePaths.LoginExternalCallback);
mockUserService.Verify(x => x.AuthenticateExternalAsync(It.IsAny<ExternalAuthenticationContext>()));
}
示例15: LoginExternalCallback_UserServiceReturnsNull_ShowError
public void LoginExternalCallback_UserServiceReturnsNull_ShowError()
{
mockUserService.Setup(x => x.AuthenticateExternalAsync(It.IsAny<ExternalAuthenticationContext>()))
.Returns(Task.FromResult((AuthenticateResult)null));
var msg = new SignInMessage();
msg.IdP = "Google";
msg.ReturnUrl = Url("authorize");
var resp1 = GetLoginPage(msg);
var sub = new Claim(Constants.ClaimTypes.Subject, "123", ClaimValueTypes.String, "Google");
SignInIdentity = new ClaimsIdentity(new Claim[] { sub }, Constants.ExternalAuthenticationType);
var resp2 = client.GetAsync(resp1.Headers.Location.AbsoluteUri).Result;
client.SetCookies(resp2.GetCookies());
var resp3 = Get(Constants.RoutePaths.LoginExternalCallback);
resp3.AssertPage("login");
var model = resp3.GetModel<LoginViewModel>();
model.ErrorMessage.Should().Be(Messages.NoMatchingExternalAccount);
}