Compare commits
No commits in common. "main" and "v0.15.0" have entirely different histories.
2
Makefile
2
Makefile
@ -5,7 +5,7 @@ KERNEL?=$$(uname -s | tr '[:upper:]' '[:lower:]')
|
|||||||
|
|
||||||
GOFMT ?= gofmt -s
|
GOFMT ?= gofmt -s
|
||||||
|
|
||||||
VERSION = 0.16.0
|
VERSION = 0.15.0
|
||||||
|
|
||||||
test: fmt-check
|
test: fmt-check
|
||||||
go test -i $(TEST) || exit 1
|
go test -i $(TEST) || exit 1
|
||||||
|
@ -17,7 +17,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "Lerentis/gitea"
|
source = "Lerentis/gitea"
|
||||||
version = "0.16.0"
|
version = "0.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "Lerentis/gitea"
|
source = "Lerentis/gitea"
|
||||||
version = "0.16.0"
|
version = "0.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,6 @@ Handling [gitea oauth application](https://docs.gitea.io/en-us/oauth2-provider/)
|
|||||||
- `name` (String) OAuth Application name
|
- `name` (String) OAuth Application name
|
||||||
- `redirect_uris` (Set of String) Accepted redirect URIs
|
- `redirect_uris` (Set of String) Accepted redirect URIs
|
||||||
|
|
||||||
### Optional
|
|
||||||
|
|
||||||
- `confidential_client` (Boolean) If set to false, it will be a public client (PKCE will be required)
|
|
||||||
|
|
||||||
### Read-Only
|
### Read-Only
|
||||||
|
|
||||||
- `client_id` (String) OAuth2 Application client id
|
- `client_id` (String) OAuth2 Application client id
|
||||||
|
@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "terraform.local/lerentis/gitea"
|
source = "terraform.local/lerentis/gitea"
|
||||||
version = "0.16.0"
|
version = "0.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ terraform {
|
|||||||
required_providers {
|
required_providers {
|
||||||
gitea = {
|
gitea = {
|
||||||
source = "Lerentis/gitea"
|
source = "Lerentis/gitea"
|
||||||
version = "0.16.0"
|
version = "0.15.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
oauth2KeyName string = "name"
|
oauth2KeyName string = "name"
|
||||||
oauth2KeyConfidentialClient string = "confidential_client"
|
oauth2KeyRedirectURIs string = "redirect_uris"
|
||||||
oauth2KeyRedirectURIs string = "redirect_uris"
|
oauth2KeyClientId string = "client_id"
|
||||||
oauth2KeyClientId string = "client_id"
|
oauth2KeyClientSecret string = "client_secret"
|
||||||
oauth2KeyClientSecret string = "client_secret"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func resourceGiteaOauthApp() *schema.Resource {
|
func resourceGiteaOauthApp() *schema.Resource {
|
||||||
@ -38,12 +37,6 @@ func resourceGiteaOauthApp() *schema.Resource {
|
|||||||
},
|
},
|
||||||
Description: "Accepted redirect URIs",
|
Description: "Accepted redirect URIs",
|
||||||
},
|
},
|
||||||
oauth2KeyConfidentialClient: {
|
|
||||||
Type: schema.TypeBool,
|
|
||||||
Optional: true,
|
|
||||||
Default: false,
|
|
||||||
Description: "If set to false, it will be a public client (PKCE will be required)",
|
|
||||||
},
|
|
||||||
oauth2KeyClientId: {
|
oauth2KeyClientId: {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Computed: true,
|
Computed: true,
|
||||||
@ -96,16 +89,9 @@ func resourceOauth2AppUpcreate(d *schema.ResourceData, meta interface{}) (err er
|
|||||||
return fmt.Errorf("attribute %s must be set and must be a string", oauth2KeyName)
|
return fmt.Errorf("attribute %s must be set and must be a string", oauth2KeyName)
|
||||||
}
|
}
|
||||||
|
|
||||||
confidentialClient, confidentialClientOk := d.Get(oauth2KeyConfidentialClient).(bool)
|
|
||||||
|
|
||||||
if !confidentialClientOk {
|
|
||||||
return fmt.Errorf("attribute %s must be set and must be a bool", oauth2KeyConfidentialClient)
|
|
||||||
}
|
|
||||||
|
|
||||||
opts := gitea.CreateOauth2Option{
|
opts := gitea.CreateOauth2Option{
|
||||||
Name: name,
|
Name: name,
|
||||||
ConfidentialClient: confidentialClient,
|
RedirectURIs: redirectURIs,
|
||||||
RedirectURIs: redirectURIs,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var oauth2 *gitea.Oauth2
|
var oauth2 *gitea.Oauth2
|
||||||
@ -113,7 +99,7 @@ func resourceOauth2AppUpcreate(d *schema.ResourceData, meta interface{}) (err er
|
|||||||
if d.IsNewResource() {
|
if d.IsNewResource() {
|
||||||
oauth2, _, err = client.CreateOauth2(opts)
|
oauth2, _, err = client.CreateOauth2(opts)
|
||||||
} else {
|
} else {
|
||||||
oauth2, err = searchOauth2AppByClientId(client, d.Id())
|
oauth2, err := searchOauth2AppByClientId(client, d.Id())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -190,10 +176,9 @@ func setOAuth2ResourceData(app *gitea.Oauth2, d *schema.ResourceData) (err error
|
|||||||
d.SetId(app.ClientID)
|
d.SetId(app.ClientID)
|
||||||
|
|
||||||
for k, v := range map[string]interface{}{
|
for k, v := range map[string]interface{}{
|
||||||
oauth2KeyName: app.Name,
|
oauth2KeyName: app.Name,
|
||||||
oauth2KeyConfidentialClient: app.ConfidentialClient,
|
oauth2KeyRedirectURIs: schema.NewSet(schema.HashString, CollapseStringList(app.RedirectURIs)),
|
||||||
oauth2KeyRedirectURIs: schema.NewSet(schema.HashString, CollapseStringList(app.RedirectURIs)),
|
oauth2KeyClientId: app.ClientID,
|
||||||
oauth2KeyClientId: app.ClientID,
|
|
||||||
} {
|
} {
|
||||||
err = d.Set(k, v)
|
err = d.Set(k, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
18
vendor/code.gitea.io/sdk/gitea/oauth2.go
generated
vendored
18
vendor/code.gitea.io/sdk/gitea/oauth2.go
generated
vendored
@ -13,13 +13,12 @@ import (
|
|||||||
|
|
||||||
// Oauth2 represents an Oauth2 Application
|
// Oauth2 represents an Oauth2 Application
|
||||||
type Oauth2 struct {
|
type Oauth2 struct {
|
||||||
ID int64 `json:"id"`
|
ID int64 `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ClientID string `json:"client_id"`
|
ClientID string `json:"client_id"`
|
||||||
ClientSecret string `json:"client_secret"`
|
ClientSecret string `json:"client_secret"`
|
||||||
RedirectURIs []string `json:"redirect_uris"`
|
RedirectURIs []string `json:"redirect_uris"`
|
||||||
ConfidentialClient bool `json:"confidential_client"`
|
Created time.Time `json:"created"`
|
||||||
Created time.Time `json:"created"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListOauth2Option for listing Oauth2 Applications
|
// ListOauth2Option for listing Oauth2 Applications
|
||||||
@ -29,9 +28,8 @@ type ListOauth2Option struct {
|
|||||||
|
|
||||||
// CreateOauth2Option required options for creating an Application
|
// CreateOauth2Option required options for creating an Application
|
||||||
type CreateOauth2Option struct {
|
type CreateOauth2Option struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ConfidentialClient bool `json:"confidential_client"`
|
RedirectURIs []string `json:"redirect_uris"`
|
||||||
RedirectURIs []string `json:"redirect_uris"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateOauth2 create an Oauth2 Application and returns a completed Oauth2 object.
|
// CreateOauth2 create an Oauth2 Application and returns a completed Oauth2 object.
|
||||||
|
Loading…
Reference in New Issue
Block a user