/// <summary> /// Retrieves the type associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// whose result returns the type associated with the specified authorization. /// </returns> public virtual Task <string> GetTypeAsync(OpenIdAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } return(Task.FromResult(authorization.Type)); }
/// <summary> /// Retrieves the scopes associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// whose result returns the scopes associated with the specified authorization. /// </returns> public virtual Task <ImmutableArray <string> > GetScopesAsync(OpenIdAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } return(Task.FromResult(authorization.Scopes)); }
/// <summary> /// Retrieves the additional properties associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation, whose /// result returns all the additional properties associated with the authorization. /// </returns> public virtual Task <JObject> GetPropertiesAsync(OpenIdAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } return(Task.FromResult(authorization.Properties ?? new JObject())); }
/// <summary> /// Retrieves the physical identifier associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation, /// whose result returns the physical identifier associated with the authorization. /// </returns> public virtual Task <string> GetPhysicalIdAsync(OpenIdAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } return(Task.FromResult(authorization.Id.ToString(CultureInfo.InvariantCulture))); }
/// <summary> /// Sets the additional properties associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="properties">The additional properties associated with the authorization </param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// </returns> public virtual Task SetPropertiesAsync(OpenIdAuthorization authorization, JObject properties, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } authorization.Properties = properties; return(Task.CompletedTask); }
/// <summary> /// Sets the type associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="type">The type associated with the authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// </returns> public virtual Task SetTypeAsync(OpenIdAuthorization authorization, string type, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } authorization.Type = type; return(Task.CompletedTask); }
/// <summary> /// Sets the subject associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="subject">The subject associated with the authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// </returns> public virtual Task SetSubjectAsync(OpenIdAuthorization authorization, string subject, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } authorization.Subject = subject; return(Task.CompletedTask); }
/// <summary> /// Creates a new authorization. /// </summary> /// <param name="authorization">The authorization to create.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// </returns> public virtual Task CreateAsync(OpenIdAuthorization authorization, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } cancellationToken.ThrowIfCancellationRequested(); _session.Save(authorization); return(_session.CommitAsync()); }
/// <summary> /// Sets the scopes associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="scopes">The scopes associated with the authorization.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// </returns> public virtual Task SetScopesAsync(OpenIdAuthorization authorization, ImmutableArray <string> scopes, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } authorization.Scopes = scopes; return(Task.CompletedTask); }
/// <summary> /// Sets the application identifier associated with an authorization. /// </summary> /// <param name="authorization">The authorization.</param> /// <param name="identifier">The unique identifier associated with the client application.</param> /// <param name="cancellationToken">The <see cref="CancellationToken"/> that can be used to abort the operation.</param> /// <returns> /// A <see cref="Task"/> that can be used to monitor the asynchronous operation. /// </returns> public virtual Task SetApplicationIdAsync(OpenIdAuthorization authorization, string identifier, CancellationToken cancellationToken) { if (authorization == null) { throw new ArgumentNullException(nameof(authorization)); } if (string.IsNullOrEmpty(identifier)) { authorization.ApplicationId = null; } else { authorization.ApplicationId = identifier; } return(Task.CompletedTask); }
public OAuth2ProviderFactory(IOptions <OpenIdAuthorization> options) { _openIdAuthorization = options.Value; }