@@ -35,10 +35,10 @@ type OAuth2Application struct {
3535 // https://datatracker.ietf.org/doc/html/rfc6749#section-2.1
3636 // "Authorization servers MUST record the client type in the client registration details"
3737 // https://datatracker.ietf.org/doc/html/rfc8252#section-8.4
38- Confidential bool `xorm:"NOT NULL DEFAULT TRUE"`
39- RedirectURIs []string `xorm:"redirect_uris JSON TEXT"`
40- CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
41- UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
38+ ConfidentialClient bool `xorm:"NOT NULL DEFAULT TRUE"`
39+ RedirectURIs []string `xorm:"redirect_uris JSON TEXT"`
40+ CreatedUnix timeutil.TimeStamp `xorm:"INDEX created"`
41+ UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
4242}
4343
4444func init () {
@@ -62,7 +62,7 @@ func (app *OAuth2Application) PrimaryRedirectURI() string {
6262
6363// ContainsRedirectURI checks if redirectURI is allowed for app
6464func (app * OAuth2Application ) ContainsRedirectURI (redirectURI string ) bool {
65- if ! app .Confidential {
65+ if ! app .ConfidentialClient {
6666 uri , err := url .Parse (redirectURI )
6767 // ignore port for http loopback uris following https://datatracker.ietf.org/doc/html/rfc8252#section-7.3
6868 if err == nil && uri .Scheme == "http" && uri .Port () != "" {
@@ -168,21 +168,21 @@ func GetOAuth2ApplicationsByUserID(ctx context.Context, userID int64) (apps []*O
168168
169169// CreateOAuth2ApplicationOptions holds options to create an oauth2 application
170170type CreateOAuth2ApplicationOptions struct {
171- Name string
172- UserID int64
173- Confidential bool
174- RedirectURIs []string
171+ Name string
172+ UserID int64
173+ ConfidentialClient bool
174+ RedirectURIs []string
175175}
176176
177177// CreateOAuth2Application inserts a new oauth2 application
178178func CreateOAuth2Application (ctx context.Context , opts CreateOAuth2ApplicationOptions ) (* OAuth2Application , error ) {
179179 clientID := uuid .New ().String ()
180180 app := & OAuth2Application {
181- UID : opts .UserID ,
182- Name : opts .Name ,
183- ClientID : clientID ,
184- RedirectURIs : opts .RedirectURIs ,
185- Confidential : opts .Confidential ,
181+ UID : opts .UserID ,
182+ Name : opts .Name ,
183+ ClientID : clientID ,
184+ RedirectURIs : opts .RedirectURIs ,
185+ ConfidentialClient : opts .ConfidentialClient ,
186186 }
187187 if err := db .Insert (ctx , app ); err != nil {
188188 return nil , err
@@ -192,11 +192,11 @@ func CreateOAuth2Application(ctx context.Context, opts CreateOAuth2ApplicationOp
192192
193193// UpdateOAuth2ApplicationOptions holds options to update an oauth2 application
194194type UpdateOAuth2ApplicationOptions struct {
195- ID int64
196- Name string
197- UserID int64
198- Confidential bool
199- RedirectURIs []string
195+ ID int64
196+ Name string
197+ UserID int64
198+ ConfidentialClient bool
199+ RedirectURIs []string
200200}
201201
202202// UpdateOAuth2Application updates an oauth2 application
@@ -217,7 +217,7 @@ func UpdateOAuth2Application(opts UpdateOAuth2ApplicationOptions) (*OAuth2Applic
217217
218218 app .Name = opts .Name
219219 app .RedirectURIs = opts .RedirectURIs
220- app .Confidential = opts .Confidential
220+ app .ConfidentialClient = opts .ConfidentialClient
221221
222222 if err = updateOAuth2Application (ctx , app ); err != nil {
223223 return nil , err
@@ -228,7 +228,7 @@ func UpdateOAuth2Application(opts UpdateOAuth2ApplicationOptions) (*OAuth2Applic
228228}
229229
230230func updateOAuth2Application (ctx context.Context , app * OAuth2Application ) error {
231- if _ , err := db .GetEngine (ctx ).ID (app .ID ).UseBool ("Confidential " ).Update (app ); err != nil {
231+ if _ , err := db .GetEngine (ctx ).ID (app .ID ).UseBool ("ConfidentialClient " ).Update (app ); err != nil {
232232 return err
233233 }
234234 return nil
0 commit comments