-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Oauth2 consumer #679
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
Oauth2 consumer #679
Changes from 7 commits
ded3513
1f94c85
642f36e
f93aad8
280913b
b597a86
8c2be7a
f392ce9
2ba7833
8e1ea96
6c98fa7
caeb911
f3f3866
047d50b
ab31c24
fe88e87
827c512
83c238b
c65a216
914f56a
b4eb93c
7a6757f
aae5f80
9151dc8
96d1af5
c3f5d36
2bf6b34
7ccbc44
084c45f
6594d76
19ddb15
57dbb74
32a4c58
770ba31
527d6e1
a7381b5
b64ee7d
5c5214a
769c747
6b16f42
0fa2e40
f54f07a
873e5b7
779e84b
61fe261
66e28df
2c11c44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,117 @@ | ||
| // Copyright 2016 Gitea. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package migrations | ||
|
Contributor
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. Why was the copyright-header removed?
Contributor
Author
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. it seems to be missing in master (https://github.com/go-gitea/gitea/blob/master/models/migrations/v16.go) and merged removed this, mine is v17.go
Contributor
Author
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. Created #992 to fix this missing header in master |
||
|
|
||
| import ( | ||
| "fmt" | ||
| "time" | ||
|
|
||
| "code.gitea.io/gitea/modules/markdown" | ||
|
|
||
| "github.com/go-xorm/xorm" | ||
| ) | ||
|
|
||
| // ExternalLoginUser makes the connecting between some existing user and additional external login sources | ||
| type ExternalLoginUser struct { | ||
| ExternalID string `xorm:"NOT NULL"` | ||
| UserID int64 `xorm:"NOT NULL"` | ||
| LoginSourceID int64 `xorm:"NOT NULL"` | ||
| // RepoUnit describes all units of a repository | ||
| type RepoUnit struct { | ||
| ID int64 | ||
| RepoID int64 `xorm:"INDEX(s)"` | ||
| Type int `xorm:"INDEX(s)"` | ||
| Index int | ||
| Config map[string]string `xorm:"JSON"` | ||
| CreatedUnix int64 `xorm:"INDEX CREATED"` | ||
| Created time.Time `xorm:"-"` | ||
| } | ||
|
|
||
| // Enumerate all the unit types | ||
| const ( | ||
| UnitTypeCode = iota + 1 // 1 code | ||
| UnitTypeIssues // 2 issues | ||
| UnitTypePRs // 3 PRs | ||
| UnitTypeCommits // 4 Commits | ||
| UnitTypeReleases // 5 Releases | ||
| UnitTypeWiki // 6 Wiki | ||
| UnitTypeSettings // 7 Settings | ||
| UnitTypeExternalWiki // 8 ExternalWiki | ||
| UnitTypeExternalTracker // 9 ExternalTracker | ||
| ) | ||
|
|
||
| // Repo describes a repository | ||
| type Repo struct { | ||
| ID int64 | ||
| EnableWiki, EnableExternalWiki, EnableIssues, EnableExternalTracker, EnablePulls bool | ||
| ExternalWikiURL, ExternalTrackerURL, ExternalTrackerFormat, ExternalTrackerStyle string | ||
| } | ||
|
|
||
| func addExternalLoginUser(x *xorm.Engine) error { | ||
| if err := x.Sync2(new(ExternalLoginUser)); err != nil { | ||
| return fmt.Errorf("Sync2: %v", err) | ||
| func addUnitsToTables(x *xorm.Engine) error { | ||
| var repos []Repo | ||
| err := x.Table("repository").Find(&repos) | ||
| if err != nil { | ||
| return fmt.Errorf("Query repositories: %v", err) | ||
| } | ||
|
|
||
| sess := x.NewSession() | ||
| defer sess.Close() | ||
|
|
||
| if err := sess.Begin(); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| var repoUnit RepoUnit | ||
| if err := sess.CreateTable(&repoUnit); err != nil { | ||
| return fmt.Errorf("CreateTable RepoUnit: %v", err) | ||
| } | ||
|
|
||
| if err := sess.CreateUniques(&repoUnit); err != nil { | ||
| return fmt.Errorf("CreateUniques RepoUnit: %v", err) | ||
| } | ||
|
|
||
| if err := sess.CreateIndexes(&repoUnit); err != nil { | ||
| return fmt.Errorf("CreateIndexes RepoUnit: %v", err) | ||
| } | ||
|
|
||
| for _, repo := range repos { | ||
| for i := 1; i <= 9; i++ { | ||
| if (i == UnitTypeWiki || i == UnitTypeExternalWiki) && !repo.EnableWiki { | ||
| continue | ||
| } | ||
| if i == UnitTypeExternalWiki && !repo.EnableExternalWiki { | ||
| continue | ||
| } | ||
| if i == UnitTypePRs && !repo.EnablePulls { | ||
| continue | ||
| } | ||
| if (i == UnitTypeIssues || i == UnitTypeExternalTracker) && !repo.EnableIssues { | ||
| continue | ||
| } | ||
| if i == UnitTypeExternalTracker && !repo.EnableExternalTracker { | ||
| continue | ||
| } | ||
|
|
||
| var config = make(map[string]string) | ||
| switch i { | ||
| case UnitTypeExternalTracker: | ||
| config["ExternalTrackerURL"] = repo.ExternalTrackerURL | ||
| config["ExternalTrackerFormat"] = repo.ExternalTrackerFormat | ||
| if len(repo.ExternalTrackerStyle) == 0 { | ||
| repo.ExternalTrackerStyle = markdown.IssueNameStyleNumeric | ||
| } | ||
| config["ExternalTrackerStyle"] = repo.ExternalTrackerStyle | ||
| case UnitTypeExternalWiki: | ||
| config["ExternalWikiURL"] = repo.ExternalWikiURL | ||
| } | ||
|
|
||
| if _, err = sess.Insert(&RepoUnit{ | ||
| RepoID: repo.ID, | ||
| Type: i, | ||
| Index: i, | ||
| Config: config, | ||
| }); err != nil { | ||
| return fmt.Errorf("Insert repo unit: %v", err) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if err := sess.Commit(); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Copyright 2016 Gitea. All rights reserved. | ||
| // Use of this source code is governed by a MIT-style | ||
| // license that can be found in the LICENSE file. | ||
|
|
||
| package migrations | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/go-xorm/xorm" | ||
| ) | ||
|
|
||
| // ExternalLoginUser makes the connecting between some existing user and additional external login sources | ||
| type ExternalLoginUser struct { | ||
| ExternalID string `xorm:"NOT NULL"` | ||
| UserID int64 `xorm:"NOT NULL"` | ||
| LoginSourceID int64 `xorm:"NOT NULL"` | ||
| } | ||
|
|
||
| func addExternalLoginUser(x *xorm.Engine) error { | ||
| if err := x.Sync2(new(ExternalLoginUser)); err != nil { | ||
| return fmt.Errorf("Sync2: %v", err) | ||
| } | ||
| return nil | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
This has to go at the end of the list
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.
there was a new one added in master, mine is after this one
https://github.com/go-gitea/gitea/pull/679/files#diff-7366023de6e87b891be868e3b8cf68e6R85-R86