Skip to content

Commit 0444a5c

Browse files
committed
Initial direct-auth project structure
Add initial interfaces to auth foundation and okta-direct-auth
1 parent 62bc87c commit 0444a5c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1227
-73
lines changed

.circleci/config.yml

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ orbs:
77

88
jobs:
99
unit-test:
10-
executor:
10+
executor: &android_executor
1111
name: android/android_docker
12-
tag: 2025.04.1
13-
environment:
12+
tag: 2025.09.1
13+
resource_class: xlarge
14+
environment: &gradle_opts_environment
1415
GRADLE_OPTS: '
15-
-Dorg.gradle.jvmargs="-Xmx3g -XX:+HeapDumpOnOutOfMemoryError"
16+
-Dorg.gradle.jvmargs="-Xmx6g -XX:+HeapDumpOnOutOfMemoryError"
1617
-Dorg.gradle.daemon=false
1718
-Dorg.gradle.workers.max=3
1819
-Dkotlin.incremental=false'
@@ -33,9 +34,7 @@ jobs:
3334
- store_artifacts:
3435
path: ~/test-results/junit
3536
snyk-scan:
36-
executor:
37-
name: android/android_docker
38-
tag: 2025.04.1
37+
executor: *android_executor
3938
steps:
4039
- attach_workspace:
4140
at: ~/project
@@ -48,9 +47,8 @@ jobs:
4847
additional-arguments: "--configuration-matching=implementation"
4948

5049
build:
51-
executor:
52-
name: android/android_docker
53-
tag: 2025.04.1
50+
executor: *android_executor
51+
environment: *gradle_opts_environment
5452
steps:
5553
- checkout
5654
- android/restore_gradle_cache
@@ -71,9 +69,7 @@ jobs:
7169
destination: apks
7270

7371
spotless-check:
74-
executor:
75-
name: android/android_docker
76-
tag: 2025.04.1
72+
executor: *android_executor
7773
steps:
7874
- checkout
7975
- android/restore_gradle_cache
@@ -83,9 +79,7 @@ jobs:
8379
- android/save_gradle_cache
8480

8581
api-check:
86-
executor:
87-
name: android/android_docker
88-
tag: 2025.04.1
82+
executor: *android_executor
8983
steps:
9084
- checkout
9185
- android/restore_gradle_cache

auth-foundation/api/auth-foundation.api

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,70 @@ public final class com/okta/authfoundation/BiometricExceptionDetails$OnAuthentic
7272
public fun toString ()Ljava/lang/String;
7373
}
7474

75+
public abstract class com/okta/authfoundation/GrantType {
76+
public synthetic fun <init> (Ljava/lang/String;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
77+
public final fun getValue ()Ljava/lang/String;
78+
}
79+
80+
public final class com/okta/authfoundation/GrantType$AuthorizationCode : com/okta/authfoundation/GrantType {
81+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$AuthorizationCode;
82+
}
83+
84+
public final class com/okta/authfoundation/GrantType$DeviceCode : com/okta/authfoundation/GrantType {
85+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$DeviceCode;
86+
}
87+
88+
public final class com/okta/authfoundation/GrantType$JwtBearer : com/okta/authfoundation/GrantType {
89+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$JwtBearer;
90+
}
91+
92+
public final class com/okta/authfoundation/GrantType$Oob : com/okta/authfoundation/GrantType {
93+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$Oob;
94+
}
95+
96+
public final class com/okta/authfoundation/GrantType$OobMfa : com/okta/authfoundation/GrantType {
97+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$OobMfa;
98+
}
99+
100+
public final class com/okta/authfoundation/GrantType$Other : com/okta/authfoundation/GrantType {
101+
public fun <init> (Ljava/lang/String;)V
102+
public final fun component1 ()Ljava/lang/String;
103+
public final fun copy (Ljava/lang/String;)Lcom/okta/authfoundation/GrantType$Other;
104+
public static synthetic fun copy$default (Lcom/okta/authfoundation/GrantType$Other;Ljava/lang/String;ILjava/lang/Object;)Lcom/okta/authfoundation/GrantType$Other;
105+
public fun equals (Ljava/lang/Object;)Z
106+
public final fun getType ()Ljava/lang/String;
107+
public fun hashCode ()I
108+
public fun toString ()Ljava/lang/String;
109+
}
110+
111+
public final class com/okta/authfoundation/GrantType$Otp : com/okta/authfoundation/GrantType {
112+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$Otp;
113+
}
114+
115+
public final class com/okta/authfoundation/GrantType$OtpMfa : com/okta/authfoundation/GrantType {
116+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$OtpMfa;
117+
}
118+
119+
public final class com/okta/authfoundation/GrantType$Password : com/okta/authfoundation/GrantType {
120+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$Password;
121+
}
122+
123+
public final class com/okta/authfoundation/GrantType$RefreshToken : com/okta/authfoundation/GrantType {
124+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$RefreshToken;
125+
}
126+
127+
public final class com/okta/authfoundation/GrantType$TokenExchange : com/okta/authfoundation/GrantType {
128+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$TokenExchange;
129+
}
130+
131+
public final class com/okta/authfoundation/GrantType$WebAuthn : com/okta/authfoundation/GrantType {
132+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$WebAuthn;
133+
}
134+
135+
public final class com/okta/authfoundation/GrantType$WebAuthnMfa : com/okta/authfoundation/GrantType {
136+
public static final field INSTANCE Lcom/okta/authfoundation/GrantType$WebAuthnMfa;
137+
}
138+
75139
public abstract interface annotation class com/okta/authfoundation/InternalAuthFoundationApi : java/lang/annotation/Annotation {
76140
}
77141

@@ -105,6 +169,78 @@ public final class com/okta/authfoundation/SdkDefaults {
105169
public final fun setGetTokenStorageFactory (Lkotlin/jvm/functions/Function0;)V
106170
}
107171

172+
public abstract interface class com/okta/authfoundation/api/http/ApiExecutor {
173+
public abstract fun execute-gIAlu-s (Lcom/okta/authfoundation/api/http/ApiRequest;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
174+
}
175+
176+
public abstract interface class com/okta/authfoundation/api/http/ApiFormRequest : com/okta/authfoundation/api/http/ApiRequest {
177+
public abstract fun contentType ()Ljava/lang/String;
178+
public abstract fun formParameters ()Ljava/util/Map;
179+
}
180+
181+
public final class com/okta/authfoundation/api/http/ApiFormRequest$DefaultImpls {
182+
public static fun query (Lcom/okta/authfoundation/api/http/ApiFormRequest;)Ljava/util/Map;
183+
}
184+
185+
public abstract interface class com/okta/authfoundation/api/http/ApiRequest {
186+
public abstract fun headers ()Ljava/util/Map;
187+
public abstract fun method ()Lcom/okta/authfoundation/api/http/ApiRequestMethod;
188+
public fun query ()Ljava/util/Map;
189+
public abstract fun url ()Ljava/lang/String;
190+
}
191+
192+
public final class com/okta/authfoundation/api/http/ApiRequest$DefaultImpls {
193+
public static fun query (Lcom/okta/authfoundation/api/http/ApiRequest;)Ljava/util/Map;
194+
}
195+
196+
public abstract interface class com/okta/authfoundation/api/http/ApiRequestBody : com/okta/authfoundation/api/http/ApiRequest {
197+
public abstract fun body ()[B
198+
public abstract fun contentType ()Ljava/lang/String;
199+
}
200+
201+
public final class com/okta/authfoundation/api/http/ApiRequestBody$DefaultImpls {
202+
public static fun query (Lcom/okta/authfoundation/api/http/ApiRequestBody;)Ljava/util/Map;
203+
}
204+
205+
public final class com/okta/authfoundation/api/http/ApiRequestMethod : java/lang/Enum {
206+
public static final field DELETE Lcom/okta/authfoundation/api/http/ApiRequestMethod;
207+
public static final field GET Lcom/okta/authfoundation/api/http/ApiRequestMethod;
208+
public static final field HEAD Lcom/okta/authfoundation/api/http/ApiRequestMethod;
209+
public static final field PATCH Lcom/okta/authfoundation/api/http/ApiRequestMethod;
210+
public static final field POST Lcom/okta/authfoundation/api/http/ApiRequestMethod;
211+
public static final field PUT Lcom/okta/authfoundation/api/http/ApiRequestMethod;
212+
public static fun getEntries ()Lkotlin/enums/EnumEntries;
213+
public static fun valueOf (Ljava/lang/String;)Lcom/okta/authfoundation/api/http/ApiRequestMethod;
214+
public static fun values ()[Lcom/okta/authfoundation/api/http/ApiRequestMethod;
215+
}
216+
217+
public abstract interface class com/okta/authfoundation/api/http/ApiResponse {
218+
public abstract fun getBody ()[B
219+
public abstract fun getContentLength ()I
220+
public abstract fun getContentType ()Ljava/lang/String;
221+
public abstract fun getHeaders ()Ljava/util/Map;
222+
public abstract fun getStatusCode ()I
223+
}
224+
225+
public abstract interface class com/okta/authfoundation/api/http/log/AuthFoundationLogger {
226+
public abstract fun write (Ljava/lang/String;Ljava/lang/Throwable;Lcom/okta/authfoundation/api/http/log/LogLevel;)V
227+
public static synthetic fun write$default (Lcom/okta/authfoundation/api/http/log/AuthFoundationLogger;Ljava/lang/String;Ljava/lang/Throwable;Lcom/okta/authfoundation/api/http/log/LogLevel;ILjava/lang/Object;)V
228+
}
229+
230+
public final class com/okta/authfoundation/api/http/log/AuthFoundationLogger$DefaultImpls {
231+
public static synthetic fun write$default (Lcom/okta/authfoundation/api/http/log/AuthFoundationLogger;Ljava/lang/String;Ljava/lang/Throwable;Lcom/okta/authfoundation/api/http/log/LogLevel;ILjava/lang/Object;)V
232+
}
233+
234+
public final class com/okta/authfoundation/api/http/log/LogLevel : java/lang/Enum {
235+
public static final field DEBUG Lcom/okta/authfoundation/api/http/log/LogLevel;
236+
public static final field ERROR Lcom/okta/authfoundation/api/http/log/LogLevel;
237+
public static final field INFO Lcom/okta/authfoundation/api/http/log/LogLevel;
238+
public static final field WARN Lcom/okta/authfoundation/api/http/log/LogLevel;
239+
public static fun getEntries ()Lkotlin/enums/EnumEntries;
240+
public static fun valueOf (Ljava/lang/String;)Lcom/okta/authfoundation/api/http/log/LogLevel;
241+
public static fun values ()[Lcom/okta/authfoundation/api/http/log/LogLevel;
242+
}
243+
108244
public abstract interface class com/okta/authfoundation/claims/ClaimsProvider {
109245
public abstract fun availableClaims ()Ljava/util/Set;
110246
public abstract fun deserializeClaim (Ljava/lang/String;Lkotlinx/serialization/DeserializationStrategy;)Ljava/lang/Object;
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright 2022-Present Okta, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.okta.authfoundation
17+
18+
/**
19+
* Represents the OAuth 2.0 grant type. Determines the mechanism Okta uses to authorize the creation of the tokens.
20+
*
21+
* This sealed class allows for a fixed set of standard grant types as well as custom ones.
22+
*
23+
* @see [RFC 6749, Section 4](https://tools.ietf.org/html/rfc6749#section-4)
24+
* @see [Okta Direct Authentication Grant Types](https://developer.okta.com/docs/reference/direct-auth/grant-types/)
25+
*/
26+
sealed class GrantType(
27+
val value: String,
28+
) {
29+
/**
30+
* The authorization code grant type is used to obtain both access tokens and refresh tokens
31+
* and is optimized for confidential clients.
32+
*
33+
* @see [RFC 6749, Section 4.1](https://tools.ietf.org/html/rfc6749#section-4.1)
34+
*/
35+
object AuthorizationCode : GrantType("authorization_code")
36+
37+
/**
38+
* The refresh token grant type is used by clients to exchange a refresh token for a new
39+
* access token when the current access token becomes invalid or expires.
40+
*
41+
* @see [RFC 6749, Section 6](https://tools.ietf.org/html/rfc6749#section-6)
42+
*/
43+
object RefreshToken : GrantType("refresh_token")
44+
45+
/**
46+
* The resource owner password credentials grant type is suitable in cases where the resource
47+
* owner has a trust relationship with the client.
48+
*
49+
* @see [RFC 6749, Section 4.3](https://tools.ietf.org/html/rfc6749#section-4.3)
50+
*/
51+
object Password : GrantType("password")
52+
53+
/**
54+
* The device authorization grant is used by browserless or input-constrained devices
55+
* in the device flow to obtain an access token.
56+
*
57+
* @see [RFC 8628](https://tools.ietf.org/html/rfc8628)
58+
*/
59+
object DeviceCode : GrantType("urn:ietf:params:oauth:grant-type:device_code")
60+
61+
/**
62+
* A grant type for exchanging a token of one type for a token of another type.
63+
*
64+
* @see [RFC 8693](https://tools.ietf.org/html/rfc8693)
65+
*/
66+
object TokenExchange : GrantType("urn:ietf:params:oauth:grant-type:token-exchange")
67+
68+
/**
69+
* A grant type that uses a JWT as an authorization grant.
70+
*
71+
* @see [RFC 7523](https://tools.ietf.org/html/rfc7523)
72+
*/
73+
object JwtBearer : GrantType("urn:ietf:params:oauth:grant-type:jwt-bearer")
74+
75+
/**
76+
* A grant type for One-Time Passcode (OTP) authentication, often used as a second factor.
77+
*
78+
* @see [Okta Direct Authentication OTP](https://developer.okta.com/docs/reference/direct-auth/grant-types/#otp)
79+
*/
80+
object Otp : GrantType("urn:okta:params:oauth:grant-type:otp")
81+
82+
/**
83+
* A grant type for Multi-Factor Authentication (MFA) using One-Time Passcodes (OTP).
84+
*
85+
* @see [Okta MFA OTP](https://developer.okta.com/docs/guides/configure-direct-auth-grants/bmfaotp/main/#about-the-direct-authentication-grant)
86+
*/
87+
object OtpMfa : GrantType("http://auth0.com/oauth/grant-type/mfa-otp")
88+
89+
/**
90+
* A grant type for Out-of-Band (OOB) authentication, such as push notifications.
91+
*
92+
* @see [Okta Direct Authentication OOB](https://developer.okta.com/docs/reference/direct-auth/grant-types/#oob)
93+
*/
94+
object Oob : GrantType("urn:okta:params:oauth:grant-type:oob")
95+
96+
/**
97+
* A grant type for Multi-Factor Authentication (MFA) using Out-of-Band (OOB) methods.
98+
*
99+
* @see [Okta MFA OOB](https://developer.okta.com/docs/guides/configure-direct-auth-grants/dmfaoobov/main/#direct-authentication-mfa-oob-okta-verify-push-flow)
100+
*/
101+
object OobMfa : GrantType("http://auth0.com/oauth/grant-type/mfa-oob")
102+
103+
/**
104+
* A grant type for WebAuthn authentication.
105+
*
106+
* @see [Okta Direct Authentication WebAuthn](https://developer.okta.com/docs/reference/direct-auth/grant-types/#webauthn)
107+
*/
108+
object WebAuthn : GrantType("urn:okta:params:oauth:grant-type:webauthn")
109+
110+
/**
111+
* A grant type for Multi-Factor Authentication (MFA) using WebAuthn.
112+
*
113+
* @see [Okta MFA WebAuthn](https://developer.okta.com/docs/guides/configure-direct-auth-grants/bmfawebauthn/main/#about-the-direct-authentication-grant)
114+
*/
115+
object WebAuthnMfa : GrantType("urn:okta:params:oauth:grant-type:mfa-webauthn")
116+
117+
/**
118+
* A custom grant type not defined in the standard set.
119+
*
120+
* @param type The string representation of the custom grant type.
121+
*/
122+
data class Other(
123+
val type: String,
124+
) : GrantType(type)
125+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2022-Present Okta, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.okta.authfoundation.api.http
17+
18+
/**
19+
* A simple abstraction for executing network requests defined by [ApiRequest] and returning [ApiResponse].
20+
*
21+
* Implementations of this interface are responsible for performing the actual network operations,
22+
* handling responses, retries, and error handling.
23+
*/
24+
interface ApiExecutor {
25+
/**
26+
* Executes the given network request asynchronously.
27+
*
28+
* Implementations of this method should be thread-safe, and should not block the calling thread.
29+
* All exceptions thrown during the execution of the request should be caught and returned as a [Result.Failure].
30+
*
31+
* @param request The [ApiRequest] to be executed.
32+
* @return A [Result] containing either the successful [ApiResponse] or an [Exception].
33+
*/
34+
suspend fun execute(request: ApiRequest): Result<ApiResponse>
35+
}

0 commit comments

Comments
 (0)