-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auth UI #411
Closed
Closed
Auth UI #411
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
9251391
Remove the old imagination on Auth UI
louischan-oursky 70fc475
Update authentication mechanism in gateway
louischan-oursky 2317002
Update route matching for gear
louischan-oursky 7b5df2b
Delete refresh_token_disabled and session_transport; rename refresh_t…
louischan-oursky 51d5260
Clarify the kinds of session
louischan-oursky cdde081
Specify Auth UI
louischan-oursky f1beac8
Upgrade client to be compatible with Client Metadata
louischan-oursky ff9c02a
Correct a serious typo
louischan-oursky 0dba914
Rename x-skygear-auth-request-result and remove `none`
louischan-oursky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,54 @@ | ||
# Delete RefreshTokenDisabled | ||
|
||
## Old SDK and old gateway behavior | ||
|
||
When the SDK receives a response with `x-skygear-try-refresh-token: true`, it tries to refresh the access token. | ||
|
||
The gateway uses this flag to determine whether it should terminate the request with 401. | ||
If RefreshTokenDisabled is true, then the request is not terminated and continue to the upstream server. | ||
If RefreshTokenDisabled is false, then the request is terminated with 401 and the header `x-skygear-try-refresh-token: true` is added. | ||
|
||
## Old SDK and new gateway behavior | ||
|
||
When the SDK receives a response with `x-skygear-try-refresh-token: true`, it tries to refresh the access token. | ||
|
||
The gateway never terminate request and write `x-skygear-session-valid` instead. It is up to the upstream server to return 401. | ||
The gateway writes `x-skygear-try-refresh-token: true` if `x-skygear-session-valid: false`. | ||
|
||
The refresh access token flow is _NOT_ broken. | ||
|
||
## New SDK and new gateway behavior | ||
|
||
When the SDK receives a response with `x-skygear-try-refresh-token: true` and it is configured to use `Authorization:`, it tries to refresh the access token. | ||
|
||
The gateway never terminate request and write `x-skygear-session-valid` instead. It is up to the upstream server to return 401. | ||
The gateway writes `x-skygear-try-refresh-token: true` if `x-skygear-session-valid: false`. | ||
|
||
The refresh access token flow is only triggered when the SDK is using `Authorization:`. | ||
|
||
# Delete SessionTransport | ||
|
||
## Old SDK and old server behavior | ||
|
||
The SDK expects the server to include the access token either in cookie or the response body. If the access token is returned in body, subsequent requests have `Authorization:` set. | ||
|
||
The server either writes the access token in cookie or includes it in the response body, according to the setting of SessionTransport. | ||
|
||
## Old SDK and new server behavior | ||
|
||
The SDK expects the server to include the access token either in cookie or the response body. If the access token is returned in body, subsequent requests have `Authorization:` set. | ||
|
||
Skygear Gateway has special routing rules that proxy `https://{app_domain}/_{gear}/` to `https://{gear_domain}/`. | ||
Skygear Gateway add a special header `x-skygear-legacy-sdk: true` to include such case. | ||
Auth Gear in this case always include the access token in cookie and in the response body. | ||
|
||
The request made by the SDK has session specified in cookie and `Authorization:`. | ||
Cookie has higher precedence. | ||
In case the session is invalid, the cookie is cleared by the gateway. The SDK triggers the refresh access token flow but it never succeed. | ||
|
||
## New SDK and new server behavior | ||
|
||
The SDK uses `Authorization:` for requests to gears and uses the configured transport for requests to the app domain. | ||
|
||
Auth Gear in this case always include the access token in the response body. | ||
A special endpoint is mounted in the app domain to accept the access token and the refresh token, and write the session token in cookie. |
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,57 +1,59 @@ | ||
# Session Configuration | ||
# Client configuration | ||
|
||
## Sample configuration | ||
|
||
In user configuration: | ||
```yaml | ||
clients: | ||
- name: Web App | ||
disabled: false | ||
api_key: XXX | ||
session_transport: cookie | ||
access_token_lifetime: 1800 | ||
session_idle_timeout_enabled: true | ||
session_idle_timeout: 300 | ||
same_site: lax | ||
- name: iOS App | ||
disabled: false | ||
api_key: YYY | ||
session_transport: header | ||
access_token_lifetime: 1800 | ||
refresh_token_disabled: false | ||
refresh_token_lifetime: 86400 | ||
session_idle_timeout_enabled: false | ||
session_idle_timeout: 300 | ||
- redirect_uris: | ||
- "https://example.com" | ||
client_name: Web App | ||
logo_uri: "https://example.com/logo.png" | ||
disabled: false | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove this, spec is not updated. |
||
api_key: XXX | ||
access_token_lifetime: 1800 | ||
session_idle_timeout_enabled: true | ||
session_idle_timeout: 300 | ||
same_site: lax | ||
- redirect_uris: | ||
- "myapp://host/path" | ||
client_name: iOS App | ||
logo_uri: "https://example.com/logo.png" | ||
disabled: false | ||
api_key: YYY | ||
access_token_lifetime: 1800 | ||
session_lifetime: 86400 | ||
session_idle_timeout_enabled: false | ||
session_idle_timeout: 300 | ||
``` | ||
|
||
## User Configuration | ||
## Parameters | ||
|
||
### Client Metadata | ||
|
||
Some parameters are defined in OIDC. See [ClientMetadata](https://openid.net/specs/openid-connect-registration-1_0.html#ClientMetadata) | ||
|
||
They are | ||
|
||
- `redirect_uris` | ||
- `client_name` | ||
- `logo_uri` | ||
|
||
### Skygear-specific | ||
|
||
The value of key `clients` is a list of client configuration: | ||
- `name`: Name of client. Show in UI (e.g. portal) | ||
- `disabled`: Indicate whether the client is disabled. | ||
- `api_key`: API key. | ||
- `session_transport`: The transport method of session tokens. | ||
Can be `cookie` or `header`. | ||
- `access_token_lifetime`: The lifetime of access token in seconds, default | ||
to 1800. | ||
- `refresh_token_disabled`: (valid for `header` transport only) | ||
Indicate whether refresh token is disabled, default | ||
to `false`. If `session_transport` is `cookie`, | ||
refresh token is disabled and this configuration | ||
has no effect. | ||
- `refresh_token_lifetime`: (valid for `header` transport only) | ||
The maximum lifetime of refresh token in seconds, | ||
- `api_key`: API key. It is going to be used as `client_id`. | ||
- `access_token_lifetime`: The lifetime of access token in seconds, default to 1800. | ||
- `session_lifetime`: The maximum lifetime of session in seconds, | ||
default to max(`access_token_lifetime`, 86400). | ||
Must greater than or equal to `access_token_lifetime`. | ||
- `session_idle_timeout_enabled`: Indicate whether session idle timeout is | ||
enabled, default to `false`. | ||
- `session_idle_timeout`: The session idle timeout in seconds, | ||
default to min(`access_token_lifetime`, 300). | ||
Must less than or equal to `access_token_lifetime`. | ||
- `same_site`: (valid for `cookie` transport only) | ||
The `SameSite` property of cookie. Can be `lax`, `strict`, or | ||
- `same_site`: The `SameSite` property of cookie. Can be `lax`, `strict`, or | ||
`none`. Default to `lax`. | ||
|
||
## Auth Gear standalone configuration | ||
## Auth Gear environment variable | ||
- `INSECURE_COOKIE`: Indicate whether session cookie should not set the `Secure` | ||
flag. Default to `false`. |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can try using silent authentication.