本文整理汇总了C#中IdentityServer3.Core.Validation.ValidatedAuthorizeRequest类的典型用法代码示例。如果您正苦于以下问题:C# ValidatedAuthorizeRequest类的具体用法?C# ValidatedAuthorizeRequest怎么用?C# ValidatedAuthorizeRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ValidatedAuthorizeRequest类属于IdentityServer3.Core.Validation命名空间,在下文中一共展示了ValidatedAuthorizeRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ValidateAuthorizeRequestAsync
/// <summary>
/// Custom validation logic for the authorize request.
/// </summary>
/// <param name="request">The validated request.</param>
/// <returns>
/// The validation result
/// </returns>
public Task<AuthorizeRequestValidationResult> ValidateAuthorizeRequestAsync(ValidatedAuthorizeRequest request)
{
return Task.FromResult(new AuthorizeRequestValidationResult
{
IsError = false
});
}
开发者ID:284247028,项目名称:IdentityServer3,代码行数:14,代码来源:DefaultCustomRequestValidator.cs
示例2: ConsentActionResult
public ConsentActionResult(IViewService viewSvc, ConsentViewModel model, ValidatedAuthorizeRequest validatedRequest)
: base(async () => await viewSvc.Consent(model, validatedRequest))
{
if (viewSvc == null) throw new ArgumentNullException("viewSvc");
if (model == null) throw new ArgumentNullException("model");
if (validatedRequest == null) throw new ArgumentNullException("validatedRequest");
}
开发者ID:Rolosoft,项目名称:IdentityServer3,代码行数:7,代码来源:ConsentActionResult.cs
示例3: ValidateAuthorizeRequestAsync
/// <summary>
///
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
public async Task<AuthorizeRequestValidationResult> ValidateAuthorizeRequestAsync(ValidatedAuthorizeRequest request)
{
//////////////////////////////////////////////////////////
// client_id must be present
/////////////////////////////////////////////////////////
var clientId = request.Raw.Get(Constants.AuthorizeRequest.ClientId);
if (clientId.IsMissingOrTooLong(_options.InputLengthRestrictions.ClientId))
{
LogError("client_id is missing or too long", request);
return Invalid(request);
}
request.ClientId = clientId;
//////////////////////////////////////////////////////////
// redirect_uri must be present, and a valid uri
//////////////////////////////////////////////////////////
var redirectUri = request.Raw.Get(Constants.AuthorizeRequest.RedirectUri);
if (redirectUri.IsMissingOrTooLong(_options.InputLengthRestrictions.RedirectUri))
{
LogError("redirect_uri is missing or too long", request);
return Invalid(request);
}
Uri uri;
if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out uri))
{
LogError("invalid redirect_uri: " + redirectUri, request);
return Invalid(request);
}
request.RedirectUri = redirectUri;
//////////////////////////////////////////////////////////
// check for valid client
//////////////////////////////////////////////////////////
var client = await _clients.FindClientByIdAsync(request.ClientId);
if (client == null || client.Enabled == false)
{
LogError("Unknown client or not enabled: " + request.ClientId, request);
return Invalid(request, ErrorTypes.User, Constants.AuthorizeErrors.UnauthorizedClient);
}
request.Client = client;
//////////////////////////////////////////////////////////
// check if redirect_uri is valid
//////////////////////////////////////////////////////////
if (await _uriValidator.IsRedirectUriValidAsync(request.RedirectUri, request.Client) == false)
{
LogError("Invalid redirect_uri: " + request.RedirectUri, request);
return Invalid(request, ErrorTypes.User, Constants.AuthorizeErrors.UnauthorizedClient);
}
return Valid(request);
}
开发者ID:kking124,项目名称:IdentityServer3,代码行数:64,代码来源:DefaultCustomClientValidator.cs
示例4: ValidateAsync
public async Task<AuthorizeRequestValidationResult> ValidateAsync(NameValueCollection parameters, ClaimsPrincipal subject = null)
{
Logger.Info("Start authorize request protocol validation");
var request = new ValidatedAuthorizeRequest
{
Options = _options,
Subject = subject ?? Principal.Anonymous
};
if (parameters == null)
{
Logger.Error("Parameters are null.");
throw new ArgumentNullException("parameters");
}
request.Raw = parameters;
// validate client_id and redirect_uri
var clientResult = await ValidateClientAsync(request);
if (clientResult.IsError)
{
return clientResult;
}
// state, response_type, response_mode
var mandatoryResult = ValidateCoreParameters(request);
if (mandatoryResult.IsError)
{
return mandatoryResult;
}
// scope, scope restrictions and plausability
var scopeResult = await ValidateScopeAsync(request);
if (scopeResult.IsError)
{
return scopeResult;
}
// nonce, prompt, acr_values, login_hint etc.
var optionalResult = ValidateOptionalParameters(request);
if (optionalResult.IsError)
{
return optionalResult;
}
// custom validator
var customResult = await _customValidator.ValidateAuthorizeRequestAsync(request);
if (customResult.IsError)
{
LogError("Error in custom validation: " + customResult.Error, request);
return Invalid(request, customResult.ErrorType, customResult.Error);
}
LogSuccess(request);
return Valid(request);
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:58,代码来源:AuthorizeRequestValidator.cs
示例5: CreateHybridFlowResponseAsync
private async Task<AuthorizeResponse> CreateHybridFlowResponseAsync(ValidatedAuthorizeRequest request)
{
Logger.Info("Creating Hybrid Flow response.");
var code = await CreateCodeAsync(request);
var response = await CreateImplicitFlowResponseAsync(request, code);
response.Code = code;
return response;
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:10,代码来源:AuthorizeResponseGenerator.cs
示例6: Anonymous_User_must_SignIn
public async Task Anonymous_User_must_SignIn()
{
var generator = new AuthorizeInteractionResponseGenerator(options, null, null, new DefaultLocalizationService());
var request = new ValidatedAuthorizeRequest
{
ClientId = "foo"
};
var result = await generator.ProcessLoginAsync(request, Principal.Anonymous);
result.IsLogin.Should().BeTrue();
}
开发者ID:nheijminkccv,项目名称:IdentityServer3,代码行数:13,代码来源:AuthorizeInteractionResponseGeneratorTests_Login.cs
示例7: Authenticated_User_must_not_SignIn
public async Task Authenticated_User_must_not_SignIn()
{
var users = new Mock<IUserService>();
var generator = new AuthorizeInteractionResponseGenerator(options, null, users.Object, new DefaultLocalizationService());
var request = new ValidatedAuthorizeRequest
{
ClientId = "foo",
Client = new Client()
};
var principal = IdentityServerPrincipal.Create("123", "dom");
var result = await generator.ProcessLoginAsync(request, principal);
result.IsLogin.Should().BeFalse();
}
开发者ID:nheijminkccv,项目名称:IdentityServer3,代码行数:16,代码来源:AuthorizeInteractionResponseGeneratorTests_Login.cs
示例8: AuthorizeRequestValidationLog
public AuthorizeRequestValidationLog(ValidatedAuthorizeRequest request)
{
Raw = request.Raw.ToDictionary();
if (request.Client != null)
{
ClientId = request.Client.ClientId;
ClientName = request.Client.ClientName;
AllowedRedirectUris = request.Client.RedirectUris;
}
if (request.Subject != null)
{
var subjectClaim = request.Subject.FindFirst(Constants.ClaimTypes.Subject);
if (subjectClaim != null)
{
SubjectId = subjectClaim.Value;
}
else
{
SubjectId = "unknown";
}
}
if (request.AuthenticationContextReferenceClasses.Any())
{
AuthenticationContextReferenceClasses = request.AuthenticationContextReferenceClasses;
}
RedirectUri = request.RedirectUri;
ResponseType = request.ResponseType;
ResponseMode = request.ResponseMode;
Flow = request.Flow;
RequestedScopes = request.RequestedScopes.ToSpaceSeparatedString();
State = request.State;
UiLocales = request.UiLocales;
Nonce = request.Nonce;
DisplayMode = request.DisplayMode;
PromptMode = request.PromptMode;
LoginHint = request.LoginHint;
MaxAge = request.MaxAge;
SessionId = request.SessionId;
CodeChallengeMethod = request.CodeChallengeMethod;
}
开发者ID:Rolosoft,项目名称:IdentityServer3,代码行数:46,代码来源:AuthorizeRequestValidationLog.cs
示例9: CreateResponseAsync
public async Task<AuthorizeResponse> CreateResponseAsync(ValidatedAuthorizeRequest request)
{
if (request.Flow == Flows.AuthorizationCode)
{
return await CreateCodeFlowResponseAsync(request);
}
if (request.Flow == Flows.Implicit)
{
return await CreateImplicitFlowResponseAsync(request);
}
if (request.Flow == Flows.Hybrid)
{
return await CreateHybridFlowResponseAsync(request);
}
Logger.Error("Unsupported flow: " + request.Flow.ToString());
throw new InvalidOperationException("invalid flow: " + request.Flow.ToString());
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:18,代码来源:AuthorizeResponseGenerator.cs
示例10: CreateCodeFlowResponseAsync
public async Task<AuthorizeResponse> CreateCodeFlowResponseAsync(ValidatedAuthorizeRequest request)
{
Logger.Info("Creating Authorization Code Flow response.");
var code = await CreateCodeAsync(request);
var response = new AuthorizeResponse
{
Request = request,
RedirectUri = request.RedirectUri,
Code = code,
State = request.State
};
if (request.IsOpenIdRequest)
{
response.SessionState = GenerateSessionStateValue(request);
}
return response;
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:21,代码来源:AuthorizeResponseGenerator.cs
示例11: AuthorizeErrorAsync
async Task<IHttpActionResult> AuthorizeErrorAsync(ErrorTypes errorType, string error, ValidatedAuthorizeRequest request)
{
await RaiseFailureEventAsync(error);
// show error message to user
if (errorType == ErrorTypes.User)
{
var env = Request.GetOwinEnvironment();
var errorModel = new ErrorViewModel
{
RequestId = env.GetRequestId(),
SiteName = _options.SiteName,
SiteUrl = env.GetIdentityServerBaseUrl(),
CurrentUser = env.GetCurrentUserDisplayName(),
LogoutUrl = env.GetIdentityServerLogoutUrl(),
ErrorMessage = LookupErrorMessage(error)
};
var errorResult = new ErrorActionResult(_viewService, errorModel);
return errorResult;
}
// return error to client
var response = new AuthorizeResponse
{
Request = request,
IsError = true,
Error = error,
State = request.State,
RedirectUri = request.RedirectUri
};
if (request.ResponseMode == Constants.ResponseModes.FormPost)
{
return new AuthorizeFormPostResult(response, Request);
}
else
{
return new AuthorizeRedirectResult(response, _options);
}
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:42,代码来源:AuthorizeEndpointController.cs
示例12: LogError
private void LogError(string message, ValidatedAuthorizeRequest request)
{
var validationLog = new AuthorizeRequestValidationLog(request);
var json = LogSerializer.Serialize(validationLog);
Logger.ErrorFormat("{0}\n {1}", message, json);
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:7,代码来源:AuthorizeRequestValidator.cs
示例13: Valid
private AuthorizeRequestValidationResult Valid(ValidatedAuthorizeRequest request)
{
var result = new AuthorizeRequestValidationResult
{
IsError = false,
ValidatedRequest = request
};
return result;
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:10,代码来源:AuthorizeRequestValidator.cs
示例14: Invalid
private AuthorizeRequestValidationResult Invalid(ValidatedAuthorizeRequest request, ErrorTypes errorType = ErrorTypes.User, string error = Constants.AuthorizeErrors.InvalidRequest)
{
var result = new AuthorizeRequestValidationResult
{
IsError = true,
Error = error,
ErrorType = errorType,
ValidatedRequest = request
};
return result;
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:12,代码来源:AuthorizeRequestValidator.cs
示例15: ValidateOptionalParameters
private AuthorizeRequestValidationResult ValidateOptionalParameters(ValidatedAuthorizeRequest request)
{
//////////////////////////////////////////////////////////
// check nonce
//////////////////////////////////////////////////////////
var nonce = request.Raw.Get(Constants.AuthorizeRequest.Nonce);
if (nonce.IsPresent())
{
if (nonce.Length > _options.InputLengthRestrictions.Nonce)
{
LogError("Nonce too long", request);
return Invalid(request, ErrorTypes.Client);
}
request.Nonce = nonce;
}
else
{
if (request.Flow == Flows.Implicit ||
request.Flow == Flows.Hybrid)
{
// only openid requests require nonce
if (request.IsOpenIdRequest)
{
LogError("Nonce required for implicit and hybrid flow with openid scope", request);
return Invalid(request, ErrorTypes.Client);
}
}
}
//////////////////////////////////////////////////////////
// check prompt
//////////////////////////////////////////////////////////
var prompt = request.Raw.Get(Constants.AuthorizeRequest.Prompt);
if (prompt.IsPresent())
{
if (Constants.SupportedPromptModes.Contains(prompt))
{
request.PromptMode = prompt;
}
else
{
Logger.Info("Unsupported prompt mode - ignored: " + prompt);
}
}
//////////////////////////////////////////////////////////
// check ui locales
//////////////////////////////////////////////////////////
var uilocales = request.Raw.Get(Constants.AuthorizeRequest.UiLocales);
if (uilocales.IsPresent())
{
if (uilocales.Length > _options.InputLengthRestrictions.UiLocale)
{
LogError("UI locale too long", request);
return Invalid(request, ErrorTypes.Client);
}
request.UiLocales = uilocales;
}
//////////////////////////////////////////////////////////
// check display
//////////////////////////////////////////////////////////
var display = request.Raw.Get(Constants.AuthorizeRequest.Display);
if (display.IsPresent())
{
if (Constants.SupportedDisplayModes.Contains(display))
{
request.DisplayMode = display;
}
Logger.Info("Unsupported display mode - ignored: " + display);
}
//////////////////////////////////////////////////////////
// check max_age
//////////////////////////////////////////////////////////
var maxAge = request.Raw.Get(Constants.AuthorizeRequest.MaxAge);
if (maxAge.IsPresent())
{
int seconds;
if (int.TryParse(maxAge, out seconds))
{
if (seconds >= 0)
{
request.MaxAge = seconds;
}
else
{
LogError("Invalid max_age.", request);
return Invalid(request, ErrorTypes.Client);
}
}
else
{
LogError("Invalid max_age.", request);
return Invalid(request, ErrorTypes.Client);
}
//.........这里部分代码省略.........
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:101,代码来源:AuthorizeRequestValidator.cs
示例16: GenerateSessionStateValue
private string GenerateSessionStateValue(ValidatedAuthorizeRequest request)
{
var sessionId = request.SessionId;
if (sessionId.IsMissing()) return null;
var salt = CryptoRandom.CreateUniqueId();
var clientId = request.ClientId;
var uri = new Uri(request.RedirectUri);
var origin = uri.Scheme + "://" + uri.Host;
if (!uri.IsDefaultPort)
{
origin += ":" + uri.Port;
}
var bytes = Encoding.UTF8.GetBytes(clientId + origin + sessionId + salt);
byte[] hash;
using (var sha = SHA256.Create())
{
hash = sha.ComputeHash(bytes);
}
return Base64Url.Encode(hash) + "." + salt;
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:25,代码来源:AuthorizeResponseGenerator.cs
示例17: Consent
public async Task<Stream> Consent (ConsentViewModel model, ValidatedAuthorizeRequest authorizeRequest)
{
return await Render (model, "Consent");
}
开发者ID:javagg,项目名称:idsvr3-mono,代码行数:4,代码来源:ViewService.cs
示例18: Consent
/// <summary>
/// Loads the HTML for the user consent page.
/// </summary>
/// <param name="model">The model.</param>
/// <param name="authorizeRequest">The validated authorize request.</param>
/// <returns>
/// Stream for the HTML
/// </returns>
public virtual Task<Stream> Consent(ConsentViewModel model, ValidatedAuthorizeRequest authorizeRequest)
{
return Render(model, ConsentView);
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:12,代码来源:DefaultViewService.cs
示例19: CreateCodeAsync
private async Task<string> CreateCodeAsync(ValidatedAuthorizeRequest request)
{
var code = new AuthorizationCode
{
Client = request.Client,
Subject = request.Subject,
SessionId = request.SessionId,
IsOpenId = request.IsOpenIdRequest,
RequestedScopes = request.ValidatedScopes.GrantedScopes,
RedirectUri = request.RedirectUri,
Nonce = request.Nonce,
WasConsentShown = request.WasConsentShown,
};
// store id token and access token and return authorization code
var id = CryptoRandom.CreateUniqueId();
await _authorizationCodes.StoreAsync(id, code);
await RaiseCodeIssuedEventAsync(id, code);
return id;
}
开发者ID:ryanmar,项目名称:IdentityServer3,代码行数:24,代码来源:AuthorizeResponseGenerator.cs
示例20: ProcessConsentAsync
public async Task<ConsentInteractionResponse> ProcessConsentAsync(ValidatedAuthorizeRequest request, UserConsent consent = null)
{
if (request == null) throw new ArgumentNullException("request");
if (request.PromptMode != null &&
request.PromptMode != Constants.PromptModes.None &&
request.PromptMode != Constants.PromptModes.Consent)
{
throw new ArgumentException("Invalid PromptMode");
}
var consentRequired = await _consent.RequiresConsentAsync(request.Client, request.Subject, request.RequestedScopes);
if (consentRequired && request.PromptMode == Constants.PromptModes.None)
{
Logger.Info("Prompt=none requested, but consent is required.");
return new ConsentInteractionResponse
{
Error = new AuthorizeError
{
ErrorType = ErrorTypes.Client,
Error = Constants.AuthorizeErrors.InteractionRequired,
ResponseMode = request.ResponseMode,
ErrorUri = request.RedirectUri,
State = request.State
}
};
}
if (request.PromptMode == Constants.PromptModes.Consent || consentRequired)
{
var response = new ConsentInteractionResponse();
// did user provide consent
if (consent == null)
{
// user was not yet shown conset screen
response.IsConsent = true;
}
else
{
request.WasConsentShown = true;
// user was shown consent -- did they say yes or no
if (consent.WasConsentGranted == false)
{
// no need to show consent screen again
// build access denied error to return to client
response.Error = new AuthorizeError {
ErrorType = ErrorTypes.Client,
Error = Constants.AuthorizeErrors.AccessDenied,
ResponseMode = request.ResponseMode,
ErrorUri = request.RedirectUri,
State = request.State
};
}
else
{
// they said yes, set scopes they chose
request.ValidatedScopes.SetConsentedScopes(consent.ScopedConsented);
if (!request.ValidatedScopes.GrantedScopes.Any())
{
// they said yes, but didn't pick any scopes
// show consent again and provide error message
response.IsConsent = true;
response.ConsentError = _localizationService.GetMessage(MessageIds.MustSelectAtLeastOnePermission);
}
else if (request.Client.AllowRememberConsent)
{
// remember consent
var scopes = Enumerable.Empty<string>();
if (consent.RememberConsent)
{
// remember what user actually selected
scopes = request.ValidatedScopes.GrantedScopes.Select(x => x.Name);
}
await _consent.UpdateConsentAsync(request.Client, request.Subject, scopes);
}
}
}
return response;
}
return new ConsentInteractionResponse();
}
开发者ID:284247028,项目名称:IdentityServer3,代码行数:89,代码来源:AuthorizeInteractionResponseGenerator.cs
注:本文中的IdentityServer3.Core.Validation.ValidatedAuthorizeRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论