Skip to content

Commit 267f6dc

Browse files
authored
Merge pull request #67 from wilhelmguo/feature/rename_oauth2_qihoo_to_oauth2
Feature/rename oauth2 qihoo to oauth2
2 parents 7b3be4e + aaa6f0d commit 267f6dc

File tree

7 files changed

+21
-28
lines changed

7 files changed

+21
-28
lines changed

hack/kubernetes/wayne/configmap.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,3 @@ data:
6767
# If set app metaData {"mode":"beta"},the app will auto redirect to BetaUrl
6868
BetaUrl = "https://beta.wayne.cloud"
6969
AppUrl = "https://www.wayne.cloud"
70-
71-
# oauth2
72-
RedirectUrl = "https://www.wayne.cloud"
73-
74-
[auth.qihoo]
75-
enabled = false
76-
#ldap config
77-
#enable ldap login
78-
[auth.ldap]
79-
enabled = false

src/backend/conf/app.conf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,8 @@ BetaUrl = "https://beta.wayne.cloud"
6565
AppUrl = "https://www.wayne.cloud"
6666

6767
# oauth2
68-
RedirectUrl = "https://www.wayne.cloud"
69-
70-
[auth.qihoo]
68+
[auth.oauth2]
69+
redirect_url = "https://www.wayne.cloud"
7170
enabled = false
7271
client_id = client
7372
client_secret = secret

src/backend/controllers/config/baseconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func (c *BaseConfigController) ListBase() {
3333
configMap["namespaceLabelKey"] = util.NamespaceLabelKey
3434
configMap["enableRobin"] = beego.AppConfig.DefaultBool("EnableRobin", false)
3535
configMap["ldapLogin"] = parseAuthEnabled("auth.ldap")
36-
configMap["qihooLogin"] = parseAuthEnabled("auth.qihoo")
36+
configMap["oauth2Login"] = parseAuthEnabled("auth.oauth2")
3737
configMap["enableApiKeys"] = beego.AppConfig.DefaultBool("EnableApiKeys", false)
3838

3939
var configs []models.Config
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
"golang.org/x/oauth2"
1010
)
1111

12-
var _ OAuther = &OAuth2Qihoo{}
12+
var _ OAuther = &OAuth2Default{}
1313

14-
type OAuth2Qihoo struct {
14+
type OAuth2Default struct {
1515
*oauth2.Config
1616
ApiUrl string
1717
ApiMapping map[string]string
1818
}
1919

20-
func (o *OAuth2Qihoo) UserInfo(token string) (*BasicUserInfo, error) {
20+
func (o *OAuth2Default) UserInfo(token string) (*BasicUserInfo, error) {
2121
userinfo := &BasicUserInfo{}
2222

2323
response, err := httplib.Get(o.ApiUrl).Header("Authorization", fmt.Sprintf("Bearer %s", token)).DoRequest()

src/backend/oauth2/oauth2.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var (
2222
)
2323

2424
const (
25-
OAuth2TypeQihoo = "qihoo"
25+
OAuth2TypeDefault = "oauth2"
2626
)
2727

2828
type BasicUserInfo struct {
@@ -51,7 +51,7 @@ type OAuther interface {
5151
}
5252

5353
func NewOAuth2Service() {
54-
allOauthes := []string{OAuth2TypeQihoo}
54+
allOauthes := []string{OAuth2TypeDefault}
5555

5656
for _, name := range allOauthes {
5757
section, err := beego.AppConfig.GetSection("auth." + name)
@@ -86,7 +86,7 @@ func NewOAuth2Service() {
8686
}
8787
}
8888

89-
OAuth2Infos[OAuth2TypeQihoo] = info
89+
OAuth2Infos[OAuth2TypeDefault] = info
9090

9191
config := oauth2.Config{
9292
ClientID: info.ClientId,
@@ -95,12 +95,12 @@ func NewOAuth2Service() {
9595
AuthURL: info.AuthUrl,
9696
TokenURL: info.TokenUrl,
9797
},
98-
RedirectURL: fmt.Sprintf("%s/login/oauth2/%s", beego.AppConfig.String("RedirectUrl"), name),
98+
RedirectURL: fmt.Sprintf("%s/login/oauth2/%s", section["redirect_url"], name),
9999
Scopes: info.Scopes,
100100
}
101101

102-
if name == OAuth2TypeQihoo {
103-
OAutherMap[OAuth2TypeQihoo] = &OAuth2Qihoo{
102+
if name == OAuth2TypeDefault {
103+
OAutherMap[OAuth2TypeDefault] = &OAuth2Default{
104104
Config: &config,
105105
ApiUrl: info.ApiUrl,
106106
ApiMapping: info.ApiMapping,

src/frontend/src/app/shared/auth-module/sign-in/sign-in.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
<button style="margin-top: 20px; width:240px;height: 40px;font-size: 16px;" type="submit" class="wayne-button" [class.normal]="isValid" [class.invalid]="!isValid" (click)="onSubmit()">立即登录</button>
1717
</div>
1818
</div>
19-
<div *ngIf="authService.config?.qihooLogin" style="padding-bottom:5px;text-align:center;">
19+
<div *ngIf="authService.config?.oauth2Login" style="padding-bottom:5px;text-align:center;">
2020
<hr style="width: 240px;"/>
21-
<button style="margin-top: 10px; width:240px;height: 40px;font-size: 16px;" type="submit" (click)="qihooLogin()" class="wayne-button normal">{{qihooLoginTitle}}</button>
21+
<button style="margin-top: 10px; width:240px;height: 40px;font-size: 16px;" type="submit" (click)="oauth2Login()" class="wayne-button normal">{{getOAuth2Title()}}</button>
2222
</div>
2323
</form>
2424
</div>

src/frontend/src/app/shared/auth-module/sign-in/sign-in.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import * as particlesJS from 'particlesjs/dist/particles';
1313
})
1414
export class SignInComponent implements OnInit {
1515
version: String = require('../../../../../package.json').version;
16-
qihooLoginTitle: String = this.authService.config['system.oauth2-title'] ? this.authService.config['system.oauth2-title'] : 'OAuth 2.0 Login';
1716
errMsg: string;
1817
username: string;
1918
password: string;
@@ -75,10 +74,15 @@ export class SignInComponent implements OnInit {
7574

7675
}
7776

78-
qihooLogin() {
77+
oauth2Login() {
7978
let currentUrl = document.location.origin;
8079
let ref = this.route.snapshot.queryParams['ref'] ? this.route.snapshot.queryParams['ref'] : '/';
81-
window.location.replace(`/login/oauth2/qihoo?next=${currentUrl}/sign-in?ref=${ref}`);
80+
window.location.replace(`/login/oauth2/oauth2?next=${currentUrl}/sign-in?ref=${ref}`);
81+
}
82+
83+
getOAuth2Title(){
84+
let oauth2Title = this.authService.config['system.oauth2-title'];
85+
return oauth2Title ? oauth2Title : 'OAuth 2.0 Login';
8286
}
8387

8488
getTitle() {

0 commit comments

Comments
 (0)