Documentation ¶
Index ¶
- func AddFilters(c context.Context, filts ...Filter) context.Context
- func IsAdmin(c context.Context) bool
- func LoginURL(c context.Context, dest string) (string, error)
- func LoginURLFederated(c context.Context, dest, identity string) (string, error)
- func LogoutURL(c context.Context, dest string) (string, error)
- func OAuthConsumerKey(c context.Context) (string, error)
- func Set(c context.Context, u RawInterface) context.Context
- func SetFactory(c context.Context, f Factory) context.Context
- type Factory
- type Filter
- type RawInterface
- type Testable
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFilters ¶
AddFilters adds RawInterface filters to the context.
func IsAdmin ¶
IsAdmin returns true if the current user is an administrator for this AppEngine project.
func LoginURL ¶
LoginURL returns a URL that, when visited, prompts the user to sign in, then redirects the user to the URL specified by dest.
func LoginURLFederated ¶
LoginURLFederated is like LoginURL but accepts a user's OpenID identifier.
func LogoutURL ¶
LogoutURL returns a URL that, when visited, signs the user out, then redirects the user to the URL specified by dest.
func OAuthConsumerKey ¶
OAuthConsumerKey returns the OAuth consumer key provided with the current request.
This method will return an error if the OAuth request was invalid.
Types ¶
type Factory ¶
type Factory func(context.Context) RawInterface
Factory is the function signature for factory methods compatible with SetFactory.
type Filter ¶
type Filter func(context.Context, RawInterface) RawInterface
Filter is the function signature for a filter user implementation. It gets the current user implementation, and returns a new user implementation backed by the one passed in.
type RawInterface ¶
type RawInterface interface { Current() *User CurrentOAuth(scopes ...string) (*User, error) IsAdmin() bool LoginURL(dest string) (string, error) LoginURLFederated(dest, identity string) (string, error) LogoutURL(dest string) (string, error) OAuthConsumerKey() (string, error) // If this implementation supports it, this will return an instance of the // Testable object for this service, which will let you 'log in' virtual users // in your test cases. If the implementation doesn't support it, it will // return nil. GetTestable() Testable }
RawInterface provides access to the "appengine/users" API methods.
func Raw ¶
func Raw(c context.Context) RawInterface
Raw pulls the user service implementation from context or nil if it wasn't set.
type Testable ¶
type Testable interface { // SetUser sets the user to a pre-populated User object. SetUser(*User) // Login will generate and set a new User object with values derived from // email clientID, and admin values. If clientID is provided, the User will // look like they logged in with OAuth. If it's empty, then this will look // like they logged in via the cookie auth method. Login(email, clientID string, admin bool) // Equivalent to SetUser(nil), but a bit more obvious to read in the code :). Logout() }
Testable is the interface that test implimentations will provide.
func GetTestable ¶
GetTestable returns a Testable for the current task queue service in c, or nil if it does not offer one.
The Testable instance will let you 'log in' virtual users in your test cases.
type User ¶
type User struct { Email string AuthDomain string Admin bool ID string ClientID string FederatedIdentity string FederatedProvider string }
User is a mimic of https://godoc.org/google.golang.org/appengine/user#User
It's provided here for convenience, and is compile-time checked to be identical.
func CurrentOAuth ¶
CurrentOAuth returns the user associated with the OAuth consumer making this request.
If the OAuth consumer did not make a valid OAuth request, or the scopes is non-empty and the current user does not have at least one of the scopes, this method will return an error.