Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. Use of this |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // source code is governed by a BSD-style license that can be found in the |
| 3 // found in the LICENSE file. | 3 // LICENSE file. |
| 4 | 4 |
| 5 module vanadium; | 5 module vanadium; |
| 6 | 6 |
| 7 // Represents the name of an application. |url| is the url of the | 7 // Represents the name of an application. |url| is the url of the application. |
| 8 // application. |qualifier| is a string that allows to tie a specific | 8 // |qualifier| is a string that allows to tie a specific instance of an |
| 9 // instance of an application to another. | 9 // application to another. |
| 10 struct AppInstanceName { | 10 struct AppInstanceName { |
| 11 string url; | 11 string url; |
| 12 string? qualifier; | 12 string? qualifier; |
| 13 }; | 13 }; |
| 14 | 14 |
| 15 // Certificate represents a human-readable name and public-key (DER encoded) pai r. | 15 // Represents a user identifier. |email| is the email address of the user, |
| 16 // The private-key for a certificate is only available for signing operations | 16 // which may be obtained through a third-party authentication flow (e.g., |
| 17 // within the principal service application. | 17 // oauth2). |
| 18 struct Certificate { | 18 struct UserId { |
|
ukode
2015/10/22 20:19:01
Is UserInfo/UserData or "User" a better option, gi
ataly
2015/10/23 21:14:53
Done, went with 'User'
| |
| 19 string extension; | 19 string email; |
| 20 array<uint8>? publickey; | 20 // TODO(ataly, ukode): Include the name of the identity provider? |
| 21 // TODO(ataly, ukode): Include the first and last name of the user? | |
| 22 // TODO(ataly, ukode): Include any unique ids assigned to the user by the | |
| 23 // identity provider? | |
| 21 }; | 24 }; |
| 22 | 25 |
| 23 // Blessing is a credential binding a user identity to a public key. The corresp onding | 26 // Certificate represents a human-readable name and public-key (DER encoded) |
| 24 // private key is only available for signing within the PrincipalService applica tion. | 27 // pair. The private-key for a certificate is only available for signing |
| 25 struct Blessing { | 28 // operations within the principal service application. |
| 26 array<Certificate> chain; | 29 struct Certificate { |
| 30 string extension; | |
| 31 array<uint8>? publickey; | |
| 27 }; | 32 }; |
| 28 | 33 |
| 29 // ChainSeparator is the separator used to join name extensions in a certificate chain. | 34 // Blessing is a credential binding a user identity to a public key. The |
| 35 // corresponding private key is only available for signing within the | |
| 36 // PrincipalService application. | |
| 37 // TODO(ataly, gauthamt): This Blessing type does not match the Vanadium | |
| 38 // WireBlessing type. For the blessing to be usable by SyncBase we will have | |
| 39 // to make it match the WireBlessing type. | |
| 40 struct Blessing { | |
| 41 array<Certificate> chain; | |
| 42 }; | |
| 43 | |
| 44 // ChainSeparator is the separator used to join name extensions in a | |
| 45 // certificate chain. | |
| 30 const string ChainSeparator = "/"; | 46 const string ChainSeparator = "/"; |
| 31 | 47 |
| 32 // A service that binds user identities to an application instance running in Mo jo | 48 // A service that binds user identities to an application instance running in |
| 49 // Mojo. An application instance may have multiple user identities with one of | |
| 50 // them set as the current identity. | |
| 33 interface PrincipalService { | 51 interface PrincipalService { |
| 34 // Login is called by an application instance (requestor_url/qualifier) that | 52 // Login is called by an application instance (requestor_url/qualifier) that |
| 35 // wants to get a user blessing. The service may obtain the user blessing | 53 // wants to get a new user identity. The service may obtain the user identity |
| 36 // through a third-party authentication flow (eg:oauth2). The user blessing | 54 // through a third-party authentication flow (e.g., oauth2) which may involve |
| 37 // is bound to a public/private key-pair that this service generates and | 55 // user intervention. The obtained identity is added to the set of |
| 38 // persists for this application instance. Returns null if login fails. | 56 // authenticated user identities of the application instance, and is also set |
| 39 Login() => (Blessing? user_blessing); | 57 // as the current user identity for the instance. |
| 58 // | |
| 59 // Additionally, the service creates a user blessing that binds the obtained | |
| 60 // user identity to the unique public/private key-pair of the instance. This | |
| 61 // key pair is generated and persisted by this service on the first Login | |
| 62 // invocation by the application instance. The constructed blessing may be | |
| 63 // obtained by invoking GetUserBlessing(). | |
|
ukode
2015/10/22 20:19:01
nit: Good to add a TODO here on how/when the bless
ataly
2015/10/23 21:14:53
Actually this particular blessing would not invali
ukode
2015/10/23 22:45:43
Acknowledged. Thanks for the clarification.
| |
| 64 // | |
| 65 // Returns the user identifier or null if an error is encountered at any | |
| 66 // stage. | |
| 67 Login() => (UserId? user_id); | |
|
ukode
2015/10/22 20:19:01
On second thought, wondering if we can set the cur
ataly
2015/10/23 21:14:53
Login does set the new identity as the current ide
ukode
2015/10/23 22:45:43
This looks good. We don't need a bool again.
| |
| 40 | 68 |
| 41 // Removes the user blessing for the application instance that invokes the | 69 // GetUsers returns all authenticated user identities and the current user |
| 42 // Logout method. | 70 // identity of the calling application instance. The user identities are a |
| 71 // result of previous Login() calls by the instance. | |
| 72 // | |
| 73 // The current user identity may be null if the instance is in logged out | |
| 74 // state (see 'Logout'). | |
| 75 GetUsers() => (array<UserId> ids, UserId? current_id); | |
| 76 | |
| 77 // SetCurrentUser sets the provided identity as the current user identity of | |
| 78 // the calling application instance. The provided identity must be present in | |
| 79 // the set of authenticated user identities for the application instance, | |
| 80 // otherwise an error is returned. | |
| 81 SetCurrentUser(UserId user_id) => (string? error); | |
| 82 | |
| 83 // Logout sets the current user identity of the calling application instance | |
|
ukode
2015/10/22 20:19:01
Does logout also delete the entry in Principal Ser
ataly
2015/10/23 21:14:53
No. Logout does not delete the user entry. It simp
ukode
2015/10/23 22:45:43
For now this looks ok, but in the future, we shoul
| |
| 84 // to null. | |
| 43 Logout(); | 85 Logout(); |
| 44 | 86 |
| 45 // GetUserBlessing returns the user blessing for a given application instance. | 87 // GetUserBlessing returns the current user blessing for a given application |
| 46 // It returns an error if the application instance has not invoked Login(). | 88 // instance. If a null application instance is provided then the current user |
| 47 GetUserBlessing(AppInstanceName app) => (Blessing? user_blessing); | 89 // blessing of the calling application instance is returned. |
| 90 // | |
| 91 // Returns null if the application instance has not invoked Login(). | |
| 92 GetUserBlessing(AppInstanceName? app) => (Blessing? user_blessing); | |
| 48 }; | 93 }; |
| 49 | |
| OLD | NEW |