mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-23 11:39:32 +02:00
Prototype device authorization flow (core)
This commit is contained in:
parent
4eda7479ce
commit
6d947ebd26
13 changed files with 331 additions and 24 deletions
|
@ -11,16 +11,22 @@ import (
|
|||
|
||||
// MockProvider provides a mocked implementation of the providers interface.
|
||||
type MockProvider struct {
|
||||
AuthenticateResponse oauth2.Token
|
||||
AuthenticateError error
|
||||
RefreshResponse oauth2.Token
|
||||
RefreshError error
|
||||
RevokeError error
|
||||
UpdateUserInfoError error
|
||||
SignInError error
|
||||
SignOutError error
|
||||
AuthenticateResponse oauth2.Token
|
||||
AuthenticateError error
|
||||
RefreshResponse oauth2.Token
|
||||
RefreshError error
|
||||
RevokeError error
|
||||
UpdateUserInfoError error
|
||||
SignInError error
|
||||
SignOutError error
|
||||
DeviceAuthResponse oauth2.DeviceAuthResponse
|
||||
DeviceAuthError error
|
||||
DeviceAccessTokenResponse oauth2.Token
|
||||
DeviceAccessTokenError error
|
||||
}
|
||||
|
||||
var _ Authenticator = MockProvider{}
|
||||
|
||||
// Authenticate is a mocked providers function.
|
||||
func (mp MockProvider) Authenticate(context.Context, string, identity.State) (*oauth2.Token, error) {
|
||||
return &mp.AuthenticateResponse, mp.AuthenticateError
|
||||
|
@ -55,3 +61,13 @@ func (mp MockProvider) SignOut(_ http.ResponseWriter, _ *http.Request, _, _, _ s
|
|||
func (mp MockProvider) SignIn(_ http.ResponseWriter, _ *http.Request, _ string) error {
|
||||
return mp.SignInError
|
||||
}
|
||||
|
||||
// DeviceAccessToken implements Authenticator.
|
||||
func (mp MockProvider) DeviceAccessToken(ctx context.Context, r *oauth2.DeviceAuthResponse, state identity.State) (*oauth2.Token, error) {
|
||||
return &mp.DeviceAccessTokenResponse, mp.DeviceAccessTokenError
|
||||
}
|
||||
|
||||
// DeviceAuth implements Authenticator.
|
||||
func (mp MockProvider) DeviceAuth(w http.ResponseWriter, r *http.Request) (*oauth2.DeviceAuthResponse, error) {
|
||||
return &mp.DeviceAuthResponse, mp.DeviceAuthError
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue