예제 #1
0
		/// <summary>
		/// Processes the authorization response from an authorization server, if available.
		/// </summary>
		/// <param name="request">The incoming HTTP request that may carry an authorization response.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>The authorization state that contains the details of the authorization.</returns>
		public Task<IAuthorizationState> ProcessUserAuthorizationAsync(
			HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken)) {
			request = request ?? this.Channel.GetRequestFromContext();
			return this.ProcessUserAuthorizationAsync(request.AsHttpRequestMessage(), cancellationToken);
		}
예제 #2
0
		/// <summary>
		/// Handles an incoming request to the authorization server's token endpoint.
		/// </summary>
		/// <param name="request">The HTTP request.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>
		/// The HTTP response to send to the client.
		/// </returns>
		public Task<HttpResponseMessage> HandleTokenRequestAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken)) {
			request = request ?? this.Channel.GetRequestFromContext();
			return this.HandleTokenRequestAsync(request.AsHttpRequestMessage(), cancellationToken);
		}
예제 #3
0
		/// <summary>
		/// Reads in a client's request for the Authorization Server to obtain permission from
		/// the user to authorize the Client'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<EndUserAuthorizationRequest> ReadAuthorizationRequestAsync(
			HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken)) {
			request = request ?? this.Channel.GetRequestFromContext();
			return this.ReadAuthorizationRequestAsync(request.AsHttpRequestMessage(), cancellationToken);
		}
예제 #4
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);
		}
예제 #5
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);
		}
예제 #6
0
		/// <summary>
		/// Processes the authorization response from an authorization server, if available. Hides WebClient.ProcessUserAuthorizationAsync
		/// </summary>
		/// <param name="request">The incoming HTTP request that may carry an authorization response.</param>
		/// <param name="cancellationToken">The cancellation token.</param>
		/// <returns>The authorization state that contains the details of the authorization.</returns>
		public new Task<IAuthorizationState> ProcessUserAuthorizationAsync(HttpRequestBase request = null, CancellationToken cancellationToken = default(CancellationToken))
		{
			// Not sexy way of getting the request, but since we can't access this.Channel.GetRequestFromContext(), we go deeper.
			request = request ?? new HttpRequestWrapper(HttpContext.Current.Request);
			return this.ProcessUserAuthorizationAsync(request.AsHttpRequestMessage(), cancellationToken);
		}