blob: 978fbac131254554ee5fcd803deba3811cc44f72 [file] [log] [blame]
Jiri Simsa756772c2015-03-25 15:40:54 -07001// 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
Todd Wang8c4e5cc2015-04-09 11:30:52 -07005// Package identity defines interfaces for Vanadium identity providers.
Asim Shankar61071792014-07-22 13:03:18 -07006package identity
7
Jiri Simsa6ac95222015-02-23 16:11:49 -08008import "v.io/v23/security"
Asim Shankarb3a82ba2014-10-29 11:41:27 -07009
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070010// OAuthBlesser exchanges OAuth access tokens for
Asim Shankar7a721752014-08-02 14:27:23 -070011// an email address from an OAuth-based identity provider and uses the email
12// address obtained to bless the client.
Asim Shankar61071792014-07-22 13:03:18 -070013//
Asim Shankar7a721752014-08-02 14:27:23 -070014// 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//
Ankurcb02c522015-08-18 19:27:43 -070018// WARNING: There is no binding between the channel over which the access
19// token was obtained (typically https) and the channel used to make the RPC
20// (a vanadium virtual circuit). Thus, if Mallory possesses the access token
21// associated with Alice's account she may be able to obtain a blessing with
22// Alice's name on it.
23//
24// TODO(ataly): Get rid of this service once all clients have been
25// switched to use the HTTP OAuthBlessingHandler service.
Asim Shankar61071792014-07-22 13:03:18 -070026type OAuthBlesser interface {
Asim Shankar7a721752014-08-02 14:27:23 -070027 // BlessUsingAccessToken uses the provided access token to obtain the email
Ankur3c33d422014-10-09 11:53:25 -070028 // address and returns a blessing along with the email address.
Todd Wang383e88c2014-12-18 01:52:34 -080029 BlessUsingAccessToken(token string) (blessing security.WireBlessings, email string | error)
Suharsh Sivakumar6069de72015-08-06 17:25:33 -070030 BlessUsingAccessTokenWithCaveats(token string, caveats []security.Caveat) (blessing security.WireBlessings, email string | error)
Jiri Simsa519c5072014-09-17 21:37:57 -070031}
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070032
33// MacaroonBlesser returns a blessing given the provided macaroon string.
34type MacaroonBlesser interface {
35 // Bless uses the provided macaroon (which contains email and caveats)
36 // to return a blessing for the client.
Todd Wang383e88c2014-12-18 01:52:34 -080037 Bless(macaroon string) (blessing security.WireBlessings | error)
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070038}
Suharsh Sivakumarc0048112015-03-19 11:48:28 -070039
40// BlessingRootResponse is the struct representing the JSON response provided
41// by the "blessing-root" route of the identity service.
42type BlessingRootResponse struct {
43 // Names of the blessings.
44 Names []string
45 // Base64 der-encoded public key.
46 PublicKey string
47}