Jiri Simsa | 756772c | 2015-03-25 15:40:54 -0700 | [diff] [blame^] | 1 | // Copyright 2015 The Vanadium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Suharsh Sivakumar | d1cc6e0 | 2015-03-16 13:58:49 -0700 | [diff] [blame] | 5 | // Package identity defines services for identity providers in the vanadium ecosystem. |
Asim Shankar | 6107179 | 2014-07-22 13:03:18 -0700 | [diff] [blame] | 6 | package identity |
| 7 | |
Jiri Simsa | 6ac9522 | 2015-02-23 16:11:49 -0800 | [diff] [blame] | 8 | import "v.io/v23/security" |
Asim Shankar | b3a82ba | 2014-10-29 11:41:27 -0700 | [diff] [blame] | 9 | |
Suharsh Sivakumar | d308c7e | 2014-10-03 12:46:50 -0700 | [diff] [blame] | 10 | // OAuthBlesser exchanges OAuth access tokens for |
Asim Shankar | 7a72175 | 2014-08-02 14:27:23 -0700 | [diff] [blame] | 11 | // an email address from an OAuth-based identity provider and uses the email |
| 12 | // address obtained to bless the client. |
Asim Shankar | 6107179 | 2014-07-22 13:03:18 -0700 | [diff] [blame] | 13 | // |
Asim Shankar | 7a72175 | 2014-08-02 14:27:23 -0700 | [diff] [blame] | 14 | // OAuth is described in RFC 6749 (http://tools.ietf.org/html/rfc6749), |
| 15 | // though the Google implementation also has informative documentation at |
| 16 | // https://developers.google.com/accounts/docs/OAuth2 |
| 17 | // |
Suharsh Sivakumar | d308c7e | 2014-10-03 12:46:50 -0700 | [diff] [blame] | 18 | // WARNING: There is no binding between the channel over which the access token |
| 19 | // was obtained (typically https) and the channel used to make the RPC (a |
Suharsh Sivakumar | 1d38dc0 | 2015-03-16 17:53:29 -0700 | [diff] [blame] | 20 | // vanadium virtual circuit). |
Suharsh Sivakumar | d308c7e | 2014-10-03 12:46:50 -0700 | [diff] [blame] | 21 | // Thus, if Mallory possesses the access token associated with Alice's account, |
| 22 | // she may be able to obtain a blessing with Alice's name on it. |
Asim Shankar | 6107179 | 2014-07-22 13:03:18 -0700 | [diff] [blame] | 23 | type OAuthBlesser interface { |
Asim Shankar | 7a72175 | 2014-08-02 14:27:23 -0700 | [diff] [blame] | 24 | // BlessUsingAccessToken uses the provided access token to obtain the email |
Ankur | 3c33d42 | 2014-10-09 11:53:25 -0700 | [diff] [blame] | 25 | // address and returns a blessing along with the email address. |
Todd Wang | 383e88c | 2014-12-18 01:52:34 -0800 | [diff] [blame] | 26 | BlessUsingAccessToken(token string) (blessing security.WireBlessings, email string | error) |
Jiri Simsa | 519c507 | 2014-09-17 21:37:57 -0700 | [diff] [blame] | 27 | } |
Suharsh Sivakumar | d308c7e | 2014-10-03 12:46:50 -0700 | [diff] [blame] | 28 | |
| 29 | // MacaroonBlesser returns a blessing given the provided macaroon string. |
| 30 | type MacaroonBlesser interface { |
| 31 | // Bless uses the provided macaroon (which contains email and caveats) |
| 32 | // to return a blessing for the client. |
Todd Wang | 383e88c | 2014-12-18 01:52:34 -0800 | [diff] [blame] | 33 | Bless(macaroon string) (blessing security.WireBlessings | error) |
Suharsh Sivakumar | d308c7e | 2014-10-03 12:46:50 -0700 | [diff] [blame] | 34 | } |
Suharsh Sivakumar | c004811 | 2015-03-19 11:48:28 -0700 | [diff] [blame] | 35 | |
| 36 | // BlessingRootResponse is the struct representing the JSON response provided |
| 37 | // by the "blessing-root" route of the identity service. |
| 38 | type BlessingRootResponse struct { |
| 39 | // Names of the blessings. |
| 40 | Names []string |
| 41 | // Base64 der-encoded public key. |
| 42 | PublicKey string |
| 43 | } |