@@ -20,8 +20,15 @@ type AssetNoContent = record {
2020 version : opt nat64;
2121};
2222type AssetsUpgradeOptions = record { clear_existing_assets : opt bool };
23+ type AuthenticateResultResponse = variant {
24+ Ok : Authentication;
25+ Err : AuthenticationError;
26+ };
27+ type Authentication = record { doc : Doc; delegation : PreparedDelegation };
28+ type AuthenticationArgs = variant { OpenId : OpenIdPrepareDelegationArgs };
2329type AuthenticationConfig = record {
2430 updated_at : opt nat64;
31+ openid : opt AuthenticationConfigOpenId;
2532 created_at : opt nat64;
2633 version : opt nat64;
2734 internet_identity : opt AuthenticationConfigInternetIdentity;
@@ -31,6 +38,14 @@ type AuthenticationConfigInternetIdentity = record {
3138 derivation_origin : opt text;
3239 external_alternative_origins : opt vec text;
3340};
41+ type AuthenticationConfigOpenId = record {
42+ observatory_id : opt principal;
43+ providers : vec record { OpenIdProvider; OpenIdProviderConfig };
44+ };
45+ type AuthenticationError = variant {
46+ PrepareDelegation : PrepareDelegationError;
47+ RegisterUser : text;
48+ };
3449type AuthenticationRules = record { allowed_callers : vec principal };
3550type CollectionType = variant { Db; Storage };
3651type CommitBatch = record {
@@ -67,6 +82,11 @@ type DbConfig = record {
6782};
6883type DelDoc = record { version : opt nat64 };
6984type DelRule = record { version : opt nat64 };
85+ type Delegation = record {
86+ pubkey : blob;
87+ targets : opt vec principal;
88+ expiration : nat64;
89+ };
7090type DeleteControllersArgs = record { controllers : vec principal };
7191type DeleteProposalAssets = record { proposal_ids : vec nat };
7292type DepositCyclesArgs = record { cycles : nat; destination_id : principal };
@@ -78,6 +98,30 @@ type Doc = record {
7898 created_at : nat64;
7999 version : opt nat64;
80100};
101+ type GetDelegationArgs = variant { OpenId : OpenIdGetDelegationArgs };
102+ type GetDelegationError = variant {
103+ JwtFindProvider : JwtFindProviderError;
104+ GetCachedJwks;
105+ NoSuchDelegation;
106+ JwtVerify : JwtVerifyError;
107+ GetOrFetchJwks : GetOrRefreshJwksError;
108+ DeriveSeedFailed : text;
109+ };
110+ type GetDelegationResultResponse = variant {
111+ Ok : SignedDelegation;
112+ Err : GetDelegationError;
113+ };
114+ type GetOrRefreshJwksError = variant {
115+ InvalidConfig : text;
116+ MissingKid;
117+ BadClaim : text;
118+ KeyNotFoundCooldown;
119+ CertificateNotFound;
120+ BadSig : text;
121+ MissingLastAttempt : text;
122+ KeyNotFound;
123+ FetchFailed : text;
124+ };
81125type HttpRequest = record {
82126 url : text;
83127 method : text;
@@ -105,6 +149,18 @@ type InitSatelliteArgs = record {
105149};
106150type InitStorageArgs = record { system_memory : opt Memory };
107151type InitUploadResult = record { batch_id : nat };
152+ type JwtFindProviderError = variant {
153+ BadClaim : text;
154+ BadSig : text;
155+ NoMatchingProvider;
156+ };
157+ type JwtVerifyError = variant {
158+ WrongKeyType;
159+ MissingKid;
160+ BadClaim : text;
161+ BadSig : text;
162+ NoKeyForKid;
163+ };
108164type ListMatcher = record {
109165 key : opt text;
110166 updated_at : opt TimestampMatcher;
@@ -154,7 +210,35 @@ type ListRulesResults = record {
154210};
155211type Memory = variant { Heap; Stable };
156212type MemorySize = record { stable : nat64; heap : nat64 };
213+ type OpenIdGetDelegationArgs = record {
214+ jwt : text;
215+ session_key : blob;
216+ salt : blob;
217+ expiration : nat64;
218+ };
219+ type OpenIdPrepareDelegationArgs = record {
220+ jwt : text;
221+ session_key : blob;
222+ salt : blob;
223+ };
224+ type OpenIdProvider = variant { Google };
225+ type OpenIdProviderConfig = record {
226+ delegation : opt OpenIdProviderDelegationConfig;
227+ client_id : text;
228+ };
229+ type OpenIdProviderDelegationConfig = record {
230+ targets : opt vec principal;
231+ max_time_to_live : opt nat64;
232+ };
157233type Permission = variant { Controllers; Private; Public; Managed };
234+ type PrepareDelegationError = variant {
235+ JwtFindProvider : JwtFindProviderError;
236+ GetCachedJwks;
237+ JwtVerify : JwtVerifyError;
238+ GetOrFetchJwks : GetOrRefreshJwksError;
239+ DeriveSeedFailed : text;
240+ };
241+ type PreparedDelegation = record { user_key : blob; expiration : nat64 };
158242type Proposal = record {
159243 status : ProposalStatus;
160244 updated_at : nat64;
@@ -198,6 +282,7 @@ type SegmentsDeploymentOptions = record {
198282 satellite_version : opt text;
199283};
200284type SetAuthenticationConfig = record {
285+ openid : opt AuthenticationConfigOpenId;
201286 version : opt nat64;
202287 internet_identity : opt AuthenticationConfigInternetIdentity;
203288 rules : opt AuthenticationRules;
@@ -240,6 +325,7 @@ type SetStorageConfig = record {
240325 raw_access : opt StorageConfigRawAccess;
241326 redirects : opt vec record { text; StorageConfigRedirect };
242327};
328+ type SignedDelegation = record { signature : blob; delegation : Delegation };
243329type StorageConfig = record {
244330 iframe : opt StorageConfigIFrame;
245331 updated_at : opt nat64;
@@ -286,6 +372,7 @@ type UploadChunk = record {
286372};
287373type UploadChunkResult = record { chunk_id : nat };
288374service : (InitSatelliteArgs) -> {
375+ authenticate : (AuthenticationArgs) -> (AuthenticateResultResponse);
289376 commit_asset_upload : (CommitBatch) -> ();
290377 commit_proposal : (CommitProposal) -> (null);
291378 commit_proposal_asset_upload : (CommitBatch) -> ();
@@ -314,6 +401,7 @@ service : (InitSatelliteArgs) -> {
314401 get_auth_config : () -> (opt AuthenticationConfig) query;
315402 get_config : () -> (Config);
316403 get_db_config : () -> (opt DbConfig) query;
404+ get_delegation : (GetDelegationArgs) -> (GetDelegationResultResponse) query;
317405 get_doc : (text, text) -> (opt Doc) query;
318406 get_many_assets : (vec record { text; text }) -> (
319407 vec record { text; opt AssetNoContent },
0 commit comments