From 8543dfc9f8a300306611bcd243da599f4db9f0bd Mon Sep 17 00:00:00 2001 From: zhouxhere Date: Wed, 27 Nov 2024 18:16:09 +0800 Subject: [PATCH] feat authRequest --- oauth/request.go | 87 ++++++++++++++++++++++++++++++++++++++++++++++++ oidc/oidc.go | 1 - 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 oauth/request.go delete mode 100644 oidc/oidc.go diff --git a/oauth/request.go b/oauth/request.go new file mode 100644 index 0000000..d700507 --- /dev/null +++ b/oauth/request.go @@ -0,0 +1,87 @@ +package oauth + +import ( + "time" + + "github.com/google/uuid" + "github.com/zitadel/oidc/v3/pkg/oidc" + "gorm.io/gorm" +) + +type AuthRequest struct { + ID uuid.UUID `gorm:"primary_key;type:char(36);default:(UUID());comment:id"` + ClientID string `gorm:"type:varchar(255);not null;comment:client_id"` + UserID string `gorm:"type:varchar(255);not null;comment:user_id"` + Scopes []string `gorm:"type:text;comment:scopes"` + CallbackURI string `gorm:"type:varchar(255);not null;comment:callback_uri"` + State string `gorm:"type:varchar(255);not null;comment:state"` + Acr string `gorm:"type:varchar(255);not null;comment:acr"` + Amr []string `gorm:"type:text;comment:amr"` + ResponseType oidc.ResponseType `gorm:"type:varchar(255);not null;comment:response_type"` + ResponseMode oidc.ResponseMode `gorm:"type:varchar(255);not null;comment:response_mode"` + done bool `gorm:"type:boolean;not null;default:false;comment:done"` + authTime time.Time `gorm:"type:timestamp;not null;comment:auth_time"` + CreatedAt time.Time `gorm:"type:timestamp;not null;comment:created_at"` + UpdatedAt time.Time `gorm:"type:timestamp;not null;comment:updated_at"` + DeletedAt gorm.DeletedAt `gorm:"type:timestamp;comment:deleted_at"` +} + +func (a *AuthRequest) GetID() string { + return a.ID.String() +} + +func (a *AuthRequest) GetACR() string { + return a.Acr +} + +func (a *AuthRequest) GetAMR() []string { + return a.Amr +} + +func (a *AuthRequest) GetAudience() []string { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetAuthTime() time.Time { + return a.authTime +} + +func (a *AuthRequest) GetClientID() string { + return a.ClientID +} + +func (a *AuthRequest) GetCodeChallenge() *oidc.CodeChallenge { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetNonce() string { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetRedirectURI() string { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetResponseType() oidc.ResponseType { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetResponseMode() oidc.ResponseMode { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetScopes() []string { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetState() string { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) GetSubject() string { + panic("not implemented") // TODO: Implement +} + +func (a *AuthRequest) Done() bool { + panic("not implemented") // TODO: Implement +} diff --git a/oidc/oidc.go b/oidc/oidc.go deleted file mode 100644 index 1df929b..0000000 --- a/oidc/oidc.go +++ /dev/null @@ -1 +0,0 @@ -package oidc