casdoor 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/images/icon128.png +0 -0
- package/images/icon16.png +0 -0
- package/images/icon32.png +0 -0
- package/images/icon48.png +0 -0
- package/manifest.json +2 -2
- package/package.json +2 -2
- package/src/sdk.js +6 -13
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# casdoor-chrome-extension
|
|
2
2
|
|
|
3
|
-
Casdoor
|
|
3
|
+
The Casdoor extension can help browser users automatically log into applications protected by [Casdoor](https://casdoor.org). The extension's code is open-sourced at: https://github.com/casdoor/casdoor-chrome-extension
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This extension is very simple to use. We will show you the steps below.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
package/images/icon128.png
CHANGED
|
Binary file
|
package/images/icon16.png
CHANGED
|
Binary file
|
package/images/icon32.png
CHANGED
|
Binary file
|
package/images/icon48.png
CHANGED
|
Binary file
|
package/manifest.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "Casdoor",
|
|
3
|
-
"description": "Casdoor
|
|
3
|
+
"description": "The Casdoor extension can help browser users automatically log into applications protected by Casdoor single-sign-on (SSO) system.",
|
|
4
4
|
"version": "1.0.0",
|
|
5
5
|
"manifest_version": 3,
|
|
6
6
|
"permissions": ["storage", "identity"],
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"https://*/*",
|
|
38
38
|
"http://*/*"
|
|
39
39
|
]
|
|
40
|
-
}
|
|
40
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "casdoor",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Casdoor
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "The Casdoor extension can help browser users automatically log into applications protected by Casdoor single-sign-on (SSO) system.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"semantic-release": "semantic-release"
|
|
7
7
|
},
|
package/src/sdk.js
CHANGED
|
@@ -31,33 +31,26 @@ class Sdk {
|
|
|
31
31
|
getSignInUrl(clientId) {
|
|
32
32
|
const endpoint = this.config.endpoint;
|
|
33
33
|
const redirectUri = this.getRedirectUri();
|
|
34
|
-
const scope = "
|
|
34
|
+
const scope = "openid";
|
|
35
35
|
const state = this.config.applicationName;
|
|
36
36
|
return `${endpoint}/login/oauth/authorize?client_id=${clientId}&response_type=token&redirect_uri=${redirectUri}&scope=${scope}&state=${state}`;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
getAccessTokenFromRedirectUrl(redirectUrl) {
|
|
40
40
|
if (redirectUrl) {
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
hashTagIndex > 0 &&
|
|
45
|
-
questionMaskIndex > 0 &&
|
|
46
|
-
hashTagIndex < questionMaskIndex
|
|
47
|
-
) {
|
|
48
|
-
// e.g. "https://${extensionId}.chromiumapp.org#token=${accessToken}?state=${state}&token_type=bearer"
|
|
49
|
-
return redirectUrl.substring(hashTagIndex + 7, questionMaskIndex);
|
|
50
|
-
}
|
|
41
|
+
const accessTokenMatch = redirectUrl.match(/#access_token=([^&]*)/);
|
|
42
|
+
const accessToken = accessTokenMatch ? accessTokenMatch[1] : "";
|
|
43
|
+
return accessToken;
|
|
51
44
|
}
|
|
52
45
|
return "";
|
|
53
46
|
}
|
|
54
47
|
|
|
55
48
|
login(func) {
|
|
56
|
-
this.getApplication().then(
|
|
49
|
+
this.getApplication().then((res) => {
|
|
57
50
|
// refer: https://developer.chrome.com/docs/extensions/reference/identity/#method-launchWebAuthFlow
|
|
58
51
|
chrome.identity.launchWebAuthFlow(
|
|
59
52
|
{
|
|
60
|
-
url: this.getSignInUrl(
|
|
53
|
+
url: this.getSignInUrl(res.data.clientId),
|
|
61
54
|
interactive: true,
|
|
62
55
|
},
|
|
63
56
|
(redirectUrl) => {
|