-
Notifications
You must be signed in to change notification settings - Fork 674
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding device authorization oauth2 flow (#313)
* Added config skip opening browser for pkce auth Signed-off-by: Prafulla Mahindrakar <[email protected]> * added docs Signed-off-by: Prafulla Mahindrakar <[email protected]> * increased the default browser session timeout to 2min Signed-off-by: Prafulla Mahindrakar <[email protected]> * Adding device flow idl changes Signed-off-by: Prafulla Mahindrakar <[email protected]> * Adding device flow orchestration Signed-off-by: Prafulla Mahindrakar <[email protected]> * lint fixes Signed-off-by: Prafulla Mahindrakar <[email protected]> * nit Signed-off-by: Prafulla Mahindrakar <[email protected]> * fixes Signed-off-by: Prafulla Mahindrakar <[email protected]> * refactor and feedback Signed-off-by: Prafulla Mahindrakar <[email protected]> * nit Signed-off-by: Prafulla Mahindrakar <[email protected]> * test fixes Signed-off-by: Prafulla Mahindrakar <[email protected]> * more test fixes Signed-off-by: Prafulla Mahindrakar <[email protected]> * feedback Signed-off-by: Prafulla Mahindrakar <[email protected]> Signed-off-by: Prafulla Mahindrakar <[email protected]>
- Loading branch information
1 parent
7da6209
commit 997b290
Showing
39 changed files
with
1,303 additions
and
353 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...eidl/clients/go/admin/pkce/token_cache.go → ...idl/clients/go/admin/cache/token_cache.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pkce | ||
package cache | ||
|
||
import "golang.org/x/oauth2" | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
...nts/go/admin/pkce/token_cache_inmemory.go → ...ts/go/admin/cache/token_cache_inmemory.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package pkce | ||
package cache | ||
|
||
import ( | ||
"fmt" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package deviceflow | ||
|
||
import "github.com/flyteorg/flytestdlib/config" | ||
|
||
// Config defines settings used for Device orchestration flow. | ||
type Config struct { | ||
TokenRefreshGracePeriod config.Duration `json:"refreshTime" pflag:",grace period from the token expiry after which it would refresh the token."` | ||
Timeout config.Duration `json:"timeout" pflag:",amount of time the device flow should complete or else it will be cancelled."` | ||
PollInterval config.Duration `json:"pollInterval" pflag:",amount of time the device flow would poll the token endpoint if auth server doesn't return a polling interval. Okta and google IDP do return an interval'"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package deviceflow | ||
|
||
import "golang.org/x/oauth2" | ||
|
||
// DeviceAuthorizationRequest sent to authorization server directly from the client app | ||
type DeviceAuthorizationRequest struct { | ||
// ClientID is the client identifier issued to the client during the registration process of OAuth app with the authorization server | ||
ClientID string `json:"client_id"` | ||
// Scope is the scope parameter of the access request | ||
Scope string `json:"scope"` | ||
} | ||
|
||
// DeviceAuthorizationResponse contains the information that the end user would use to authorize the app requesting the | ||
// resource access. | ||
type DeviceAuthorizationResponse struct { | ||
// DeviceCode unique device code generated by the authorization server. | ||
DeviceCode string `json:"device_code"` | ||
// UserCode unique code generated for the user to enter on another device | ||
UserCode string `json:"user_code"` | ||
// VerificationURI url endpoint of the authorization server which host the device and app verification | ||
VerificationURI string `json:"verification_uri"` | ||
// VerificationURIComplete url endpoint of the authorization server which host the device and app verification along with user code | ||
VerificationURIComplete string `json:"verification_uri_complete"` | ||
// ExpiresIn lifetime in seconds of the "device_code" and "user_code" | ||
ExpiresIn int64 `json:"expires_in"` | ||
// Interval minimum amount of time in secs the client app should wait between polling requests to the token endpoint. | ||
Interval int64 `json:"interval"` | ||
} | ||
|
||
type DeviceAccessTokenRequest struct { | ||
// ClientID is the client identifier issued to the client during the registration process of OAuth app with the authorization server | ||
ClientID string `json:"client_id"` | ||
// DeviceCode unique device code generated by the authorization server. | ||
DeviceCode string `json:"device_code"` | ||
// Value MUST be set to "urn:ietf:params:oauth:grant-type:device_code" | ||
GrantType string `json:"grant_type"` | ||
} | ||
|
||
type DeviceAccessTokenResponse struct { | ||
oauth2.Token | ||
Error string `json:"error"` | ||
} |
Oops, something went wrong.