Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions hack/kubernetes/wayne/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,3 @@ data:
# If set app metaData {"mode":"beta"},the app will auto redirect to BetaUrl
BetaUrl = "https://beta.wayne.cloud"
AppUrl = "https://www.wayne.cloud"

# oauth2
RedirectUrl = "https://www.wayne.cloud"

[auth.qihoo]
enabled = false
#ldap config
#enable ldap login
[auth.ldap]
enabled = false
5 changes: 2 additions & 3 deletions src/backend/conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ BetaUrl = "https://beta.wayne.cloud"
AppUrl = "https://www.wayne.cloud"

# oauth2
RedirectUrl = "https://www.wayne.cloud"

[auth.qihoo]
[auth.oauth2]
redirect_url = "https://www.wayne.cloud"
enabled = false
client_id = client
client_secret = secret
Expand Down
2 changes: 1 addition & 1 deletion src/backend/controllers/config/baseconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (c *BaseConfigController) ListBase() {
configMap["namespaceLabelKey"] = util.NamespaceLabelKey
configMap["enableRobin"] = beego.AppConfig.DefaultBool("EnableRobin", false)
configMap["ldapLogin"] = parseAuthEnabled("auth.ldap")
configMap["qihooLogin"] = parseAuthEnabled("auth.qihoo")
configMap["oauth2Login"] = parseAuthEnabled("auth.oauth2")
configMap["enableApiKeys"] = beego.AppConfig.DefaultBool("EnableApiKeys", false)

var configs []models.Config
Expand Down
6 changes: 3 additions & 3 deletions src/backend/oauth2/qihoo.go → src/backend/oauth2/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import (
"golang.org/x/oauth2"
)

var _ OAuther = &OAuth2Qihoo{}
var _ OAuther = &OAuth2Default{}

type OAuth2Qihoo struct {
type OAuth2Default struct {
*oauth2.Config
ApiUrl string
ApiMapping map[string]string
}

func (o *OAuth2Qihoo) UserInfo(token string) (*BasicUserInfo, error) {
func (o *OAuth2Default) UserInfo(token string) (*BasicUserInfo, error) {
userinfo := &BasicUserInfo{}

response, err := httplib.Get(o.ApiUrl).Header("Authorization", fmt.Sprintf("Bearer %s", token)).DoRequest()
Expand Down
12 changes: 6 additions & 6 deletions src/backend/oauth2/oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
)

const (
OAuth2TypeQihoo = "qihoo"
OAuth2TypeDefault = "oauth2"
)

type BasicUserInfo struct {
Expand Down Expand Up @@ -51,7 +51,7 @@ type OAuther interface {
}

func NewOAuth2Service() {
allOauthes := []string{OAuth2TypeQihoo}
allOauthes := []string{OAuth2TypeDefault}

for _, name := range allOauthes {
section, err := beego.AppConfig.GetSection("auth." + name)
Expand Down Expand Up @@ -86,7 +86,7 @@ func NewOAuth2Service() {
}
}

OAuth2Infos[OAuth2TypeQihoo] = info
OAuth2Infos[OAuth2TypeDefault] = info

config := oauth2.Config{
ClientID: info.ClientId,
Expand All @@ -95,12 +95,12 @@ func NewOAuth2Service() {
AuthURL: info.AuthUrl,
TokenURL: info.TokenUrl,
},
RedirectURL: fmt.Sprintf("%s/login/oauth2/%s", beego.AppConfig.String("RedirectUrl"), name),
RedirectURL: fmt.Sprintf("%s/login/oauth2/%s", section["redirect_url"], name),
Scopes: info.Scopes,
}

if name == OAuth2TypeQihoo {
OAutherMap[OAuth2TypeQihoo] = &OAuth2Qihoo{
if name == OAuth2TypeDefault {
OAutherMap[OAuth2TypeDefault] = &OAuth2Default{
Config: &config,
ApiUrl: info.ApiUrl,
ApiMapping: info.ApiMapping,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
<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>
</div>
</div>
<div *ngIf="authService.config?.qihooLogin" style="padding-bottom:5px;text-align:center;">
<div *ngIf="authService.config?.oauth2Login" style="padding-bottom:5px;text-align:center;">
<hr style="width: 240px;"/>
<button style="margin-top: 10px; width:240px;height: 40px;font-size: 16px;" type="submit" (click)="qihooLogin()" class="wayne-button normal">{{qihooLoginTitle}}</button>
<button style="margin-top: 10px; width:240px;height: 40px;font-size: 16px;" type="submit" (click)="oauth2Login()" class="wayne-button normal">{{getOAuth2Title()}}</button>
</div>
</form>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import * as particlesJS from 'particlesjs/dist/particles';
})
export class SignInComponent implements OnInit {
version: String = require('../../../../../package.json').version;
qihooLoginTitle: String = this.authService.config['system.oauth2-title'] ? this.authService.config['system.oauth2-title'] : 'OAuth 2.0 Login';
errMsg: string;
username: string;
password: string;
Expand Down Expand Up @@ -75,10 +74,15 @@ export class SignInComponent implements OnInit {

}

qihooLogin() {
oauth2Login() {
let currentUrl = document.location.origin;
let ref = this.route.snapshot.queryParams['ref'] ? this.route.snapshot.queryParams['ref'] : '/';
window.location.replace(`/login/oauth2/qihoo?next=${currentUrl}/sign-in?ref=${ref}`);
window.location.replace(`/login/oauth2/oauth2?next=${currentUrl}/sign-in?ref=${ref}`);
}

getOAuth2Title(){
let oauth2Title = this.authService.config['system.oauth2-title'];
return oauth2Title ? oauth2Title : 'OAuth 2.0 Login';
}

getTitle() {
Expand Down