Compare commits

...

6 Commits

Author SHA1 Message Date
Tobias Trabelsi
601cc245ef bump version
Some checks failed
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is failing
2023-07-20 09:12:14 +02:00
Tobias Trabelsi
340bcd48fe
Merge pull request #46 from deblasis/fix/gitea_oauth2_app_confidential_client
All checks were successful
continuous-integration/drone/push Build is passing
Support `gitea_oauth2_app` `confidential_client` flag
2023-07-20 09:09:50 +02:00
Alessandro De Blasis
2d7147442b fix(oauth): updates 2023-07-19 19:56:50 +00:00
Alessandro De Blasis
c707cba22e fix(gitea_oauth_app): added missing createoptions and resourcedata 2023-07-13 11:32:30 +00:00
Alessandro De Blasis
5b14a5d789 docs(oauth2_app): docs 2023-07-11 21:19:53 +00:00
Alessandro De Blasis
707443c6d2 feat(gitea_oauth_app): support 2023-07-11 21:18:08 +00:00
8 changed files with 44 additions and 23 deletions

View File

@ -5,7 +5,7 @@ KERNEL?=$$(uname -s | tr '[:upper:]' '[:lower:]')
GOFMT ?= gofmt -s
VERSION = 0.15.0
VERSION = 0.16.0
test: fmt-check
go test -i $(TEST) || exit 1

View File

@ -17,7 +17,7 @@ terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.15.0"
version = "0.16.0"
}
}
}

View File

@ -17,7 +17,7 @@ terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.15.0"
version = "0.16.0"
}
}
}

View File

@ -20,6 +20,10 @@ Handling [gitea oauth application](https://docs.gitea.io/en-us/oauth2-provider/)
- `name` (String) OAuth Application name
- `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
- `client_id` (String) OAuth2 Application client id

View File

@ -2,7 +2,7 @@ terraform {
required_providers {
gitea = {
source = "terraform.local/lerentis/gitea"
version = "0.15.0"
version = "0.16.0"
}
}
}

View File

@ -2,7 +2,7 @@ terraform {
required_providers {
gitea = {
source = "Lerentis/gitea"
version = "0.15.0"
version = "0.16.0"
}
}
}

View File

@ -9,6 +9,7 @@ import (
const (
oauth2KeyName string = "name"
oauth2KeyConfidentialClient string = "confidential_client"
oauth2KeyRedirectURIs string = "redirect_uris"
oauth2KeyClientId string = "client_id"
oauth2KeyClientSecret string = "client_secret"
@ -37,6 +38,12 @@ func resourceGiteaOauthApp() *schema.Resource {
},
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: {
Type: schema.TypeString,
Computed: true,
@ -89,8 +96,15 @@ func resourceOauth2AppUpcreate(d *schema.ResourceData, meta interface{}) (err er
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{
Name: name,
ConfidentialClient: confidentialClient,
RedirectURIs: redirectURIs,
}
@ -99,7 +113,7 @@ func resourceOauth2AppUpcreate(d *schema.ResourceData, meta interface{}) (err er
if d.IsNewResource() {
oauth2, _, err = client.CreateOauth2(opts)
} else {
oauth2, err := searchOauth2AppByClientId(client, d.Id())
oauth2, err = searchOauth2AppByClientId(client, d.Id())
if err != nil {
return err
@ -177,6 +191,7 @@ func setOAuth2ResourceData(app *gitea.Oauth2, d *schema.ResourceData) (err error
for k, v := range map[string]interface{}{
oauth2KeyName: app.Name,
oauth2KeyConfidentialClient: app.ConfidentialClient,
oauth2KeyRedirectURIs: schema.NewSet(schema.HashString, CollapseStringList(app.RedirectURIs)),
oauth2KeyClientId: app.ClientID,
} {

View File

@ -18,6 +18,7 @@ type Oauth2 struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
RedirectURIs []string `json:"redirect_uris"`
ConfidentialClient bool `json:"confidential_client"`
Created time.Time `json:"created"`
}
@ -29,6 +30,7 @@ type ListOauth2Option struct {
// CreateOauth2Option required options for creating an Application
type CreateOauth2Option struct {
Name string `json:"name"`
ConfidentialClient bool `json:"confidential_client"`
RedirectURIs []string `json:"redirect_uris"`
}