Example #1
0
 public IAuthorizationState ProcessUserAuthorizationAsync(
     HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken)
     )
 {
     request = request ?? this.Channel.GetRequestFromContext();
     return(this.ProcessUserAuthorizationAsync(request.AsHttpRequestMessage(), cancellationToken));
 }
Example #2
0
        /// <summary>
        /// Discovers what access the client should have considering the access token in the current request.
        /// </summary>
        /// <param name="httpRequestInfo">The HTTP request info.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <param name="requiredScopes">The set of scopes required to approve this request.</param>
        /// <returns>
        /// The access token describing the authorization the client has.  Never <c>null</c>.
        /// </returns>
        /// <exception cref="ProtocolFaultResponseException">Thrown when the client is not authorized.  This exception should be caught and the
        /// <see cref="ProtocolFaultResponseException.ErrorResponseMessage" /> message should be returned to the client.</exception>
        public virtual Task <AccessToken> GetAccessTokenAsync(HttpRequestBase httpRequestInfo = null, CancellationToken cancellationToken = default(CancellationToken), params string[] requiredScopes)
        {
            Requires.NotNull(requiredScopes, "requiredScopes");
            RequiresEx.ValidState(this.ScopeSatisfiedCheck != null, Strings.RequiredPropertyNotYetPreset);

            httpRequestInfo = httpRequestInfo ?? this.Channel.GetRequestFromContext();
            return(this.GetAccessTokenAsync(httpRequestInfo.AsHttpRequestMessage(), cancellationToken, requiredScopes));
        }
 /// <summary>
 /// Gets the incoming OpenID request if there is one, or null if none was detected.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// The request that the hosting Provider should possibly process and then transmit the response for.
 /// </returns>
 /// <exception cref="InvalidOperationException">Thrown if <see cref="HttpContext.Current">HttpContext.Current</see> == <c>null</c>.</exception>
 /// <exception cref="ProtocolException">Thrown if the incoming message is recognized but deviates from the protocol specification irrecoverably.</exception>
 /// <remarks>
 ///   <para>Requests may be infrastructural to OpenID and allow auto-responses, or they may
 /// be authentication requests where the Provider site has to make decisions based
 /// on its own user database and policies.</para>
 ///   <para>Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.</para>
 /// </remarks>
 public Task <IRequest> GetRequestAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     request = request ?? this.Channel.GetRequestFromContext();
     return(this.GetRequestAsync(request.AsHttpRequestMessage(), cancellationToken));
 }
Example #4
0
 /// <summary>
 /// Processes the response received in a popup window or iframe to an AJAX-directed OpenID authentication.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// The HTTP response to send to this HTTP request.
 /// </returns>
 /// <remarks>
 /// Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.
 /// </remarks>
 public Task <HttpResponseMessage> ProcessResponseFromPopupAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     request = request ?? this.Channel.GetRequestFromContext();
     return(this.ProcessResponseFromPopupAsync(request.AsHttpRequestMessage(), cancellationToken));
 }
Example #5
0
 /// <summary>
 /// Gets an authentication response from a Provider.
 /// </summary>
 /// <param name="request">The request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// The processed authentication response if there is any; <c>null</c> otherwise.
 /// </returns>
 /// <remarks>
 /// Requires an <see cref="HttpContext.Current">HttpContext.Current</see> context.
 /// </remarks>
 public Task <IAuthenticationResponse> GetResponseAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     request = request ?? this.channel.GetRequestFromContext();
     return(this.GetResponseAsync(request.AsHttpRequestMessage(), cancellationToken));
 }
Example #6
0
 /// <summary>
 /// Gets the authorization (access token) for accessing some protected resource.
 /// </summary>
 /// <param name="request">The incoming HTTP request.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>The authorization message sent by the Consumer, or null if no authorization message is attached.</returns>
 /// <remarks>
 /// This method verifies that the access token and token secret are valid.
 /// It falls on the caller to verify that the access token is actually authorized
 /// to access the resources being requested.
 /// </remarks>
 /// <exception cref="ProtocolException">Thrown if an unexpected message is attached to the request.</exception>
 public Task <AccessProtectedResourceRequest> ReadProtectedResourceAuthorizationAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     request = request ?? this.channel.GetRequestFromContext();
     return(this.ReadProtectedResourceAuthorizationAsync(request.AsHttpRequestMessage(), cancellationToken));
 }
Example #7
0
 /// <summary>
 /// Reads in a Consumer's request for the Service Provider to obtain permission from
 /// the user to authorize the Consumer's access of some protected resource(s).
 /// </summary>
 /// <param name="request">The HTTP request to read from.</param>
 /// <param name="cancellationToken">The cancellation token.</param>
 /// <returns>
 /// The incoming request, or null if no OAuth message was attached.
 /// </returns>
 /// <exception cref="ProtocolException">Thrown if an unexpected OAuth message is attached to the incoming request.</exception>
 public Task <UserAuthorizationRequest> ReadAuthorizationRequestAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken))
 {
     request = request ?? this.channel.GetRequestFromContext();
     return(this.ReadAuthorizationRequestAsync(request.AsHttpRequestMessage(), cancellationToken));
 }