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 identity. |email| is the email address of the user, which m ay |
16 // The private-key for a certificate is only available for signing operations | 16 // be obtained through a third-party authentication flow (e.g., oauth2). |
17 // within the principal service application. | 17 struct User { |
18 struct Certificate { | 18 string email; |
19 string extension; | 19 Blessing blessing; |
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. A detailed decription of the blessings | |
37 // concept can be found at: | |
38 // https://github.com/vanadium/docs/blob/master/concepts/security.md | |
39 // TODO(ataly, gauthamt): This Blessing type does not match the Vanadium | |
40 // WireBlessing type. For the blessing to be usable by SyncBase we will have | |
41 // to make it match the WireBlessing type. | |
42 struct Blessing { | |
43 array<Certificate> chain; | |
44 }; | |
45 | |
46 // ChainSeparator is the separator used to join name extensions in a | |
47 // certificate chain. | |
30 const string ChainSeparator = "/"; | 48 const string ChainSeparator = "/"; |
31 | 49 |
32 // A service that binds user identities to an application instance running in Mo jo | 50 // A service that binds user identities to an application instance running in |
51 // Mojo. An application instance may have multiple user identities with one of | |
52 // them set as the current identity. | |
33 interface PrincipalService { | 53 interface PrincipalService { |
34 // Login is called by an application instance (requestor_url/qualifier) that | 54 // 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 | 55 // 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 | 56 // 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 | 57 // user intervention. The obtained identity is added to the set of |
38 // persists for this application instance. Returns null if login fails. | 58 // authenticated user identities of the application instance, and is also set |
39 Login() => (Blessing? user_blessing); | 59 // as the current user identity for the application instance. |
60 // | |
61 // Additionally, the service creates a user blessing that binds the obtained | |
62 // email address of the user to the unique public/private key-pair of the | |
63 // applicaiton instance. | |
64 // | |
65 // Returns the user identity or null if an error is encountered at any | |
66 // stage. | |
67 Login() => (User? user); | |
40 | 68 |
41 // Removes the user blessing for the application instance that invokes the | 69 // Logout sets the current user identity of the calling application instance |
42 // Logout method. | 70 // to null. |
43 Logout(); | 71 Logout(); |
44 | 72 |
45 // GetUserBlessing returns the user blessing for a given application instance. | 73 // GetUser returns the current user identity for a given application instance. |
46 // It returns an error if the application instance has not invoked Login(). | 74 // If a null application instance is provided then the current user identity |
47 GetUserBlessing(AppInstanceName app) => (Blessing? user_blessing); | 75 // of the calling application instance is returned. |
76 // | |
77 // Returns null if the application instance has not invoked Login or if the in stance | |
ashankar
2015/11/04 00:37:10
Are .mojom files supposed to follow an 80-char lin
ataly
2015/11/04 21:22:51
Done.
| |
78 // is in logged out state (see 'Logout'). | |
79 GetUser(AppInstanceName? app) => (User? user); | |
80 | |
81 // SetUser sets the current user identity of the calling application | |
82 // instance. The provided identity must be present in the set of logged-in | |
83 // user identities for the application instance, otherwise an error is returne d. | |
84 SetUser(User user) => (string? error); | |
85 | |
86 // GetLoggedInUsers returns all authenticated user identities of the calling | |
87 // application instance. The user identities are a result of previous Login ca lls | |
88 // by the application instance. | |
89 GetLoggedInUsers() => (array<User> ids); | |
48 }; | 90 }; |
49 | |
OLD | NEW |