Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
b4646b6c
Commit
b4646b6c
authored
Apr 12, 2016
by
Kevin Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to use a generic oauth that conforms to the github style.
Enables users to set their own link text.
parent
603e5fe0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
4 deletions
+29
-4
pkg/api/login.go
+2
-0
pkg/setting/setting_oauth.go
+3
-2
pkg/social/social.go
+17
-1
public/app/core/controllers/login_ctrl.js
+3
-1
public/app/partials/login.html
+4
-0
No files found.
pkg/api/login.go
View file @
b4646b6c
...
@@ -27,6 +27,8 @@ func LoginView(c *middleware.Context) {
...
@@ -27,6 +27,8 @@ func LoginView(c *middleware.Context) {
viewData
.
Settings
[
"googleAuthEnabled"
]
=
setting
.
OAuthService
.
Google
viewData
.
Settings
[
"googleAuthEnabled"
]
=
setting
.
OAuthService
.
Google
viewData
.
Settings
[
"githubAuthEnabled"
]
=
setting
.
OAuthService
.
GitHub
viewData
.
Settings
[
"githubAuthEnabled"
]
=
setting
.
OAuthService
.
GitHub
viewData
.
Settings
[
"genericOAuthEnabled"
]
=
setting
.
OAuthService
.
Generic
viewData
.
Settings
[
"oauthProviderName"
]
=
setting
.
OAuthService
.
OAuthProviderName
viewData
.
Settings
[
"disableUserSignUp"
]
=
!
setting
.
AllowUserSignUp
viewData
.
Settings
[
"disableUserSignUp"
]
=
!
setting
.
AllowUserSignUp
viewData
.
Settings
[
"loginHint"
]
=
setting
.
LoginHint
viewData
.
Settings
[
"loginHint"
]
=
setting
.
LoginHint
viewData
.
Settings
[
"allowUserPassLogin"
]
=
setting
.
AllowUserPassLogin
viewData
.
Settings
[
"allowUserPassLogin"
]
=
setting
.
AllowUserPassLogin
...
...
pkg/setting/setting_oauth.go
View file @
b4646b6c
...
@@ -11,8 +11,9 @@ type OAuthInfo struct {
...
@@ -11,8 +11,9 @@ type OAuthInfo struct {
}
}
type
OAuther
struct
{
type
OAuther
struct
{
GitHub
,
Google
,
Twitter
bool
GitHub
,
Google
,
Twitter
,
Generic
bool
OAuthInfos
map
[
string
]
*
OAuthInfo
OAuthInfos
map
[
string
]
*
OAuthInfo
OAuthProviderName
string
}
}
var
OAuthService
*
OAuther
var
OAuthService
*
OAuther
pkg/social/social.go
View file @
b4646b6c
...
@@ -42,7 +42,7 @@ func NewOAuthService() {
...
@@ -42,7 +42,7 @@ func NewOAuthService() {
setting
.
OAuthService
=
&
setting
.
OAuther
{}
setting
.
OAuthService
=
&
setting
.
OAuther
{}
setting
.
OAuthService
.
OAuthInfos
=
make
(
map
[
string
]
*
setting
.
OAuthInfo
)
setting
.
OAuthService
.
OAuthInfos
=
make
(
map
[
string
]
*
setting
.
OAuthInfo
)
allOauthes
:=
[]
string
{
"github"
,
"google"
}
allOauthes
:=
[]
string
{
"github"
,
"google"
,
"generic-oauth"
}
for
_
,
name
:=
range
allOauthes
{
for
_
,
name
:=
range
allOauthes
{
sec
:=
setting
.
Cfg
.
Section
(
"auth."
+
name
)
sec
:=
setting
.
Cfg
.
Section
(
"auth."
+
name
)
...
@@ -98,6 +98,22 @@ func NewOAuthService() {
...
@@ -98,6 +98,22 @@ func NewOAuthService() {
allowSignup
:
info
.
AllowSignup
,
allowSignup
:
info
.
AllowSignup
,
}
}
}
}
// Generic - Uses the same scheme as Github.
if
name
==
"generic-oauth"
{
setting
.
OAuthService
.
Generic
=
true
setting
.
OAuthService
.
OAuthProviderName
=
sec
.
Key
(
"oauth_provider_name"
)
.
String
()
teamIds
:=
sec
.
Key
(
"team_ids"
)
.
Ints
(
","
)
allowedOrganizations
:=
sec
.
Key
(
"allowed_organizations"
)
.
Strings
(
" "
)
SocialMap
[
"generic-oauth"
]
=
&
SocialGithub
{
Config
:
&
config
,
allowedDomains
:
info
.
AllowedDomains
,
apiUrl
:
info
.
ApiUrl
,
allowSignup
:
info
.
AllowSignup
,
teamIds
:
teamIds
,
allowedOrganizations
:
allowedOrganizations
,
}
}
}
}
}
}
...
...
public/app/core/controllers/login_ctrl.js
View file @
b4646b6c
...
@@ -17,8 +17,10 @@ function (angular, coreModule, config) {
...
@@ -17,8 +17,10 @@ function (angular, coreModule, config) {
$scope
.
googleAuthEnabled
=
config
.
googleAuthEnabled
;
$scope
.
googleAuthEnabled
=
config
.
googleAuthEnabled
;
$scope
.
githubAuthEnabled
=
config
.
githubAuthEnabled
;
$scope
.
githubAuthEnabled
=
config
.
githubAuthEnabled
;
$scope
.
oauthEnabled
=
config
.
githubAuthEnabled
||
config
.
googleAuthEnabled
;
$scope
.
oauthEnabled
=
config
.
githubAuthEnabled
||
config
.
googleAuthEnabled
||
config
.
genericOAuthEnabled
;
$scope
.
allowUserPassLogin
=
config
.
allowUserPassLogin
;
$scope
.
allowUserPassLogin
=
config
.
allowUserPassLogin
;
$scope
.
genericOAuthEnabled
=
config
.
genericOAuthEnabled
;
$scope
.
oauthProviderName
=
config
.
oauthProviderName
;
$scope
.
disableUserSignUp
=
config
.
disableUserSignUp
;
$scope
.
disableUserSignUp
=
config
.
disableUserSignUp
;
$scope
.
loginHint
=
config
.
loginHint
;
$scope
.
loginHint
=
config
.
loginHint
;
...
...
public/app/partials/login.html
View file @
b4646b6c
...
@@ -59,6 +59,10 @@
...
@@ -59,6 +59,10 @@
<i
class=
"fa fa-github"
></i>
<i
class=
"fa fa-github"
></i>
with Github
with Github
</a>
</a>
<a
class=
"btn btn-large btn-generic-oauth"
href=
"login/generic-oauth"
target=
"_self"
ng-if=
"genericOAuthEnabled"
>
<i
class=
"fa fa-gear"
></i>
with {{oauthProviderName || "OAuth 2"}}
</a>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment