blob: f761fad6330d346816e029a7f2130454c812ec86 [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
Suharsh Sivakumard1cc6e02015-03-16 13:58:49 -07005// Package identity defines services for identity providers in the vanadium ecosystem.
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//
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070018// 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 Sivakumar1d38dc02015-03-16 17:53:29 -070020// vanadium virtual circuit).
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070021// 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 Shankar61071792014-07-22 13:03:18 -070023type OAuthBlesser interface {
Asim Shankar7a721752014-08-02 14:27:23 -070024 // BlessUsingAccessToken uses the provided access token to obtain the email
Ankur3c33d422014-10-09 11:53:25 -070025 // address and returns a blessing along with the email address.
Todd Wang383e88c2014-12-18 01:52:34 -080026 BlessUsingAccessToken(token string) (blessing security.WireBlessings, email string | error)
Jiri Simsa519c5072014-09-17 21:37:57 -070027}
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070028
29// MacaroonBlesser returns a blessing given the provided macaroon string.
30type MacaroonBlesser interface {
31 // Bless uses the provided macaroon (which contains email and caveats)
32 // to return a blessing for the client.
Todd Wang383e88c2014-12-18 01:52:34 -080033 Bless(macaroon string) (blessing security.WireBlessings | error)
Suharsh Sivakumard308c7e2014-10-03 12:46:50 -070034}
Suharsh Sivakumarc0048112015-03-19 11:48:28 -070035
36// BlessingRootResponse is the struct representing the JSON response provided
37// by the "blessing-root" route of the identity service.
38type BlessingRootResponse struct {
39 // Names of the blessings.
40 Names []string
41 // Base64 der-encoded public key.
42 PublicKey string
43}