public async Task <IAuthorisationServer> CreateAuthorisationServer(CreateAuthorisationServerOptions options, CancellationToken cancellationToken = default(CancellationToken)) { var requestUrl = _client.Configuration.BuildUrl("/api/v1/authorizationServers"); return(await _client.PostAsync <AuthorisationServer>(requestUrl.AbsoluteUri, options, cancellationToken)); }
public async Task <IIdentityProviderCredentialKey> CreateCredentialKey(CreateIdentityProviderCredentialKeyOptions options, CancellationToken cancellationToken = default(CancellationToken)) { var requestUrl = _client.Configuration.BuildUrl("/api/v1/idps/credentials/keys"); return(await _client.PostAsync <IdentityProviderCredentialKey>(requestUrl.AbsoluteUri, options, cancellationToken)); }
public async Task <ITrustedOrigin> CreateTrustedOrigin(CreateTrustedOriginOptions options, CancellationToken cancellationToken = default(CancellationToken)) { var requestUrl = _client.Configuration.BuildUrl("/api/v1/trustedOrigins"); return(await _client.PostAsync <TrustedOrigin>(requestUrl.AbsoluteUri, options, cancellationToken)); }
/// <inheritdoc /> public async Task <ICreatedOrganisation> CreateOrganisation( CreateOrganisationOptions options, CancellationToken cancellationToken = default(CancellationToken)) { var requestUrl = _client.Configuration.BuildUrl("/api/v1/orgs"); return(await _client.PostAsync <CreatedOrganisation>(requestUrl.AbsoluteUri, options, cancellationToken)); }
/// <summary> /// Create an Org2Org Application /// </summary> public static async Task <IOrg2OrgApplication> CreateOrg2OrgApplicationAsync( this IOktaClient spokeClient, CreateOrg2OrgApplicationOptions options, CancellationToken cancellationToken) { var requestUrl = spokeClient.Configuration.BuildUrl("/api/v1/apps"); return(await spokeClient.PostAsync <Org2OrgApplication>(requestUrl.AbsoluteUri, options, cancellationToken)); }
public async Task <ISchema> CreateUserProperty(string propertyName, ISchemaDefinitionProperty options, CancellationToken cancellationToken = default(CancellationToken)) { var createOptions = new CreateUserPropertyOptions { Definitions = new SchemaCustomDefinitionSet() { Custom = new SchemaDefinition() { Id = "#custom", Type = "object", Properties = new Resource() { [propertyName] = options }, Required = new List <string>() } } }; var requestUrl = _client.Configuration.BuildUrl("/api/v1/meta/schemas/user/default"); return(await _client.PostAsync <Schema>(requestUrl.AbsoluteUri, createOptions, cancellationToken)); }
public async Task <HttpResponseMessage> CreateUser(UserModel user) { var responseMessage = new HttpResponseMessage(); try { //Map to Okta model var oktaUser = new UserOktaModel() { Profile = new Profile() { FirstName = user.FirstName, LastName = user.LastName, Email = user.UserName, Login = user.UserName }, Credentials = new Credentials() { Password = new Password() { Value = user.Password } } }; await _oktaClient.PostAsync($"{ _oktaClient.Configuration.OrgUrl}/api/v1/users?activate=true", oktaUser); responseMessage.StatusCode = HttpStatusCode.OK; } catch (Exception ex) { responseMessage.StatusCode = HttpStatusCode.InternalServerError; responseMessage.ReasonPhrase = string.Format($"{ex.Message}"); } return(responseMessage); }
private CSEntryChangeResult PutCSEntryChangeUpdate(CSEntryChange csentry, ExportContext context) { IOktaClient client = ((OktaConnectionContext)context.ConnectionContext).Client; IUser user = null; bool partial = true; if (csentry.AttributeChanges.Any(t => t.ModificationType == AttributeModificationType.Delete || t.Name == "suspended" || t.DataType == AttributeType.Reference // this should only need to include MV attributes, but there's an issue where MIM sends an attribute update with a value delete for a single valued ref that it doesn't know about )) { logger.Trace($"Getting user {csentry.DN} for FULL update"); user = AsyncHelper.RunSync(client.Users.GetUserAsync(csentry.DN, context.CancellationTokenSource.Token), context.CancellationTokenSource.Token); partial = false; } else { user = new User(); user.Profile = new UserProfile(); } foreach (AttributeChange change in csentry.AttributeChanges) { if (change.Name == "suspended") { bool suspend; if (change.ModificationType == AttributeModificationType.Delete) { suspend = false; } else { suspend = change.GetValueAdd <bool>(); } if (user.Status == UserStatus.Active && suspend) { logger.Info($"Suspending user {user.Id}"); AsyncHelper.RunSync(user.SuspendAsync(context.CancellationTokenSource.Token), context.CancellationTokenSource.Token); } else if (user.Status == UserStatus.Suspended && !suspend) { logger.Info($"Unsuspending user {user.Id}"); AsyncHelper.RunSync(user.UnsuspendAsync(context.CancellationTokenSource.Token), context.CancellationTokenSource.Token); } } else { if (change.IsMultiValued) { IList <object> existingItems = user.Profile[change.Name] as IList <object> ?? new List <object>(); IList <object> newList = change.ApplyAttributeChanges((IList)existingItems); user.Profile[change.Name] = newList; logger.Info($"{change.ModificationType} {change.Name} -> {newList.Count} items"); } else { user.Profile[change.Name] = change.GetValueAdd <object>(); logger.Info($"{change.ModificationType} {change.Name} -> {user.Profile[change.Name] ?? "<null>"}"); } } } if (partial) { AsyncHelper.RunSync(client.PostAsync <User>($"/api/v1/users/{csentry.DN}", user, context.CancellationTokenSource.Token), context.CancellationTokenSource.Token); } else { AsyncHelper.RunSync(client.Users.UpdateUserAsync(user, csentry.DN, context.CancellationTokenSource.Token), context.CancellationTokenSource.Token); } return(CSEntryChangeResult.Create(csentry.Identifier, null, MAExportError.Success)); }
/// <inheritdoc /> public async Task <IPopulatedToken> CreateToken(CreateTokenOptions options, CancellationToken cancellationToken = default(CancellationToken)) { var requestUrl = _client.Configuration.BuildUrl("/api/internal/tokens?expand=user"); return(await _client.PostAsync <PopulatedToken>(requestUrl.AbsoluteUri, options, cancellationToken)); }