8000 OIDC improvements by vincent-stytch · Pull Request #60 · stytchauth/stytch-java · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

OIDC improvements #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import com.stytch.java.b2b.models.organizationsmembers.DeleteTOTPRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.DeleteTOTPResponse
import com.stytch.java.b2b.models.organizationsmembers.GetRequest
import com.stytch.java.b2b.models.organizationsmembers.GetResponse
import com.stytch.java.b2b.models.organizationsmembers.OIDCProviderInformationRequest
import com.stytch.java.b2b.models.organizationsmembers.OIDCProvidersResponse
import com.stytch.java.b2b.models.organizationsmembers.ReactivateRequest
import com.stytch.java.b2b.models.organizationsmembers.ReactivateRequestOptions
import com.stytch.java.b2b.models.organizationsmembers.ReactivateResponse
Expand Down Expand Up @@ -311,6 +313,15 @@ public interface Members {
*/
public fun dangerouslyGetCompletable(data: DangerouslyGetRequest): CompletableFuture<StytchResult<GetResponse>>

public suspend fun oidcProviders(data: OIDCProviderInformationRequest): StytchResult<OIDCProvidersResponse>

public fun oidcProviders(
data: OIDCProviderInformationRequest,
callback: (StytchResult<OIDCProvidersResponse>) -> Unit,
)

public fun oidcProvidersCompletable(data: OIDCProviderInformationRequest): CompletableFuture<StytchResult<OIDCProvidersResponse>>

/**
* Unlinks a retired email address from a specified by their `organization_id` and `member_id`. The email address
* to be retired can be identified in the request body by either its `email_id`, its `email_address`, or both. If using
Expand Down Expand Up @@ -672,6 +683,31 @@ internal class MembersImpl(
dangerouslyGet(data)
}.asCompletableFuture()

override suspend fun oidcProviders(data: OIDCProviderInformationRequest): StytchResult<OIDCProvidersResponse> =
withContext(Dispatchers.IO) {
var headers = emptyMap<String, String>()

val asJson = moshi.adapter(OIDCProviderInformationRequest::class.java).toJson(data)
val type = Types.newParameterizedType(Map::class.java, String::class.java, Any::class.java)
val adapter: JsonAdapter<Map<String, Any>> = moshi.adapter(type)
val asMap = adapter.fromJson(asJson) ?: emptyMap()
httpClient.get("/v1/b2b/organizations/${data.organizationId}/members/${data.memberId}/oidc_providers", asMap, headers)
}

override fun oidcProviders(
data: OIDCProviderInformationRequest,
callback: (StytchResult<OIDCProvidersResponse>) -> Unit,
) {
coroutineScope.launch {
callback(oidcProviders(data))
}
}

override fun oidcProvidersCompletable(data: OIDCProviderInformationRequest): CompletableFuture<StytchResult<OIDCProvidersResponse>> =
coroutineScope.async {
oidcProviders(data)
}.asCompletableFuture()

override suspend fun unlinkRetiredEmail(
data: UnlinkRetiredEmailRequest,
methodOptions: UnlinkRetiredEmailRequestOptions?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,26 @@ public data class OAuthRegistration
val locale: String? = null,
)

@JsonClass(generateAdapter = true)
public data class OIDCProviderInfo
@JvmOverloads
constructor(
@Json(name = "provider_subject")
val providerSubject: String,
@Json(name = "id_token")
val idToken: String,
@Json(name = "access_token")
val accessToken: String,
@Json(name = "access_token_expires_in")
val accessTokenExpiresIn: Int,
@Json(name = "scopes")
val scopes: List<String>,
@Json(name = "connection_id")
val connectionId: String,
@Json(name = "refresh_token")
val refreshToken: String? = null,
)

@JsonClass(generateAdapter = true)
public data class Organization
@JvmOverloads
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package com.stytch.java.b2b.models.organizationsmembers
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import com.stytch.java.b2b.models.organizations.Member
import com.stytch.java.b2b.models.organizations.OIDCProviderInfo
import com.stytch.java.b2b.models.organizations.Organization
import com.stytch.java.b2b.models.organizations.ResultsMetadata
import com.stytch.java.b2b.models.organizations.SearchQuery
Expand Down Expand Up @@ -587,6 +588,30 @@ public data class GetResponse
val statusCode: Int,
)

@JsonClass(generateAdapter = true)
public data class OIDCProviderInformationRequest
@JvmOverloads
constructor(
@Json(name = "organization_id")
val organizationId: String,
@Json(name = "member_id")
val memberId: String,
@Json(name = "include_refresh_token")
val includeRefreshToken: Boolean? = null,
)

@JsonClass(generateAdapter = true)
public data class OIDCProvidersResponse
@JvmOverloads
constructor(
@Json(name = "request_id")
val requestId: String,
@Json(name = "registrations")
val registrations: List<OIDCProviderInfo>,
@Json(name = "status_code")
val statusCode: Int,
)

/**
* Request type for `Members.reactivate`.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ public data class OIDCConnection
val jwksURL: String,
@Json(name = "identity_provider")
val identityProvider: String,
@Json(name = "custom_scopes")
val customScopes: String,
@Json(name = "attribute_mapping")
val attributeMapping: Map<String, Any?>? = emptyMap(),
)

@JsonClass(generateAdapter = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,18 @@ public data class UpdateConnectionRequest
*/
@Json(name = "identity_provider")
val identityProvider: UpdateConnectionRequestIdentityProvider? = null,
/**
* Include a space-separated list of custom scopes that you'd like to include. Note that this list must be URL encoded,
* e.g. the spaces must be expressed as %20.
*/
@Json(name = "custom_scopes")
val customScopes: String? = null,
/**
* An object that represents the attributes used to identify a Member. This object will map the IdP-defined User
* attributes to Stytch-specific values, which will appear on the member's Trusted Metadata.
*/
@Json(name = "attribute_mapping")
val attributeMapping: Map<String, Any?>? = emptyMap(),
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ public data class UpdateConnectionRequest
val samlGroupImplicitRoleAssignments: List<SAMLGroupImplicitRoleAssignment>? = emptyList(),
/**
* An alternative URL to use for the Audience Restriction. This value can be used when you wish to migrate an existing
* SAML integration to Stytch with zero downtime.
* SAML integration to Stytch with zero downtime. Read our
* [SSO migration guide](https://stytch.com/docs/b2b/guides/migrations/additional-migration-considerations) for more info.
*/
@Json(name = "alternative_audience_uri")
val alternativeAudienceUri: String? = null,
Expand Down
2 changes: 1 addition & 1 deletion stytch/src/main/kotlin/com/stytch/java/common/Version.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package com.stytch.java.common

internal const val VERSION = "6.2.0"
internal const val VERSION = "6.3.0"
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ public enum class AuthenticationFactorDeliveryMethod {

@Json(name = "oauth_exchange_hubspot")
OAUTH_EXCHANGE_HUBSPOT,

@Json(name = "oauth_exchange_github")
OAUTH_EXCHANGE_GITHUB,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an issue to have some of the GitHub type declarations in here even though it's not live yet?

}

@JsonClass(generateAdapter = false)
Expand Down Expand Up @@ -326,6 +329,8 @@ public data class AuthenticationFactor
val slackOAuthExchangeFactor: SlackOAuthExchangeFactor? = null,
@Json(name = "hubspot_oauth_exchange_factor")
val hubspotOAuthExchangeFactor: HubspotOAuthExchangeFactor? = null,
@Json(name = "github_oauth_exchange_factor")
val githubOAuthExchangeFactor: GithubOAuthExchangeFactor? = null,
)

@JsonClass(generateAdapter = true)
Expand Down Expand Up @@ -455,6 +460,14 @@ public data class GitLabOAuthFactor
val emailId: String? = null,
)

@JsonClass(generateAdapter = true)
public data class GithubOAuthExchangeFactor
@JvmOverloads
constructor(
@Json(name = "email_id")
val emailId: String,
)

@JsonClass(generateAdapter = true)
public data class GithubOAuthFactor
@JvmOverloads
Expand Down
2 changes: 1 addition & 1 deletion version.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "6.2.0"
version = "6.3.0"
Loading
0