Skip to content

Commit

Permalink
Merge pull request #126 from piny940/userinfo-claim
Browse files Browse the repository at this point in the history
Userinfoを作成
  • Loading branch information
piny940 authored Nov 30, 2024
2 parents a594e2f + d1cf76d commit 24032a8
Show file tree
Hide file tree
Showing 28 changed files with 768 additions and 320 deletions.
4 changes: 3 additions & 1 deletion docs/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"sub": "id:{userID};name:{username}",
"iat": 0000000000,
"jti": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // 32字のランダム文字列
"scope": "openid profile email" // スペース区切り
"scope": "openid profile email", // スペース区切り
"auth_time": 0000000000, // 認証日時
}
```

Expand All @@ -33,5 +34,6 @@
"exp": 0000000000,
"iat": 0000000000, // トークン発行日時
"jti": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", // 32字のランダム文字列
"auth_time": 0000000000, // 認証日時
}
```
43 changes: 41 additions & 2 deletions frontend/src/utils/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ export interface paths {
patch?: never
trace?: never
}
'/userinfo': {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
/** Get userinfo */
get: operations['Userinfo_getUserinfo']
put?: never
post?: never
delete?: never
options?: never
head?: never
patch?: never
trace?: never
}
'/users/signup': {
parameters: {
query?: never
Expand Down Expand Up @@ -278,6 +295,10 @@ export interface components {
id: number
name: string
}
'Userinfo.UserinfoRes': {
sub: string
name?: string
}
'Users.ReqSignup': {
name: string
password: string
Expand Down Expand Up @@ -735,7 +756,6 @@ export interface operations {
/** @description There is no content to send for this request, but the headers may be useful. */
204: {
headers: {
'set-cookie': string
[name: string]: unknown
}
content?: never
Expand Down Expand Up @@ -766,13 +786,32 @@ export interface operations {
/** @description There is no content to send for this request, but the headers may be useful. */
204: {
headers: {
'set-cookie': string
[name: string]: unknown
}
content?: never
}
}
}
Userinfo_getUserinfo: {
parameters: {
query?: never
header?: never
path?: never
cookie?: never
}
requestBody?: never
responses: {
/** @description The request has succeeded. */
200: {
headers: {
[name: string]: unknown
}
content: {
'application/json': components['schemas']['Userinfo.UserinfoRes']
}
}
}
}
UsersInterface_signup: {
parameters: {
query?: never
Expand Down
2 changes: 1 addition & 1 deletion internal/api/approval.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func (s *Server) ApprovalsInterfaceApprove(ctx context.Context, request ApprovalsInterfaceApproveRequestObject) (ApprovalsInterfaceApproveResponseObject, error) {
session, err := CurrentUser(ctx)
session, err := s.Auth.CurrentUser(ctx)
if err != nil {
s.logger.Errorf("failed to get current user: %v", err)
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions internal/api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *Server) ClientsInterfaceGetClient(ctx context.Context, request ClientsI
// ----------------------------------- private api -------------------------------

func (s *Server) AccountClientsCreateClient(ctx context.Context, request AccountClientsCreateClientRequestObject) (AccountClientsCreateClientResponseObject, error) {
session, err := CurrentUser(ctx)
session, err := s.Auth.CurrentUser(ctx)
if err != nil {
s.logger.Errorf("failed to get current user: %v", err)
return nil, err
Expand All @@ -55,7 +55,7 @@ func (s *Server) AccountClientsCreateClient(ctx context.Context, request Account
}

func (s *Server) AccountClientsDeleteClient(ctx context.Context, request AccountClientsDeleteClientRequestObject) (AccountClientsDeleteClientResponseObject, error) {
session, err := CurrentUser(ctx)
session, err := s.Auth.CurrentUser(ctx)
if err != nil {
s.logger.Errorf("failed to get current user: %v", err)
return nil, err
Expand All @@ -68,7 +68,7 @@ func (s *Server) AccountClientsDeleteClient(ctx context.Context, request Account
}

func (s *Server) AccountClientsListClients(ctx context.Context, request AccountClientsListClientsRequestObject) (AccountClientsListClientsResponseObject, error) {
session, err := CurrentUser(ctx)
session, err := s.Auth.CurrentUser(ctx)
if err != nil {
s.logger.Errorf("failed to get current user: %v", err)
return nil, err
Expand All @@ -92,7 +92,7 @@ func (s *Server) AccountClientsListClients(ctx context.Context, request AccountC
}

func (s *Server) AccountClientsGetClient(ctx context.Context, request AccountClientsGetClientRequestObject) (AccountClientsGetClientResponseObject, error) {
session, err := CurrentUser(ctx)
session, err := s.Auth.CurrentUser(ctx)
if err != nil {
s.logger.Errorf("failed to get current user: %v", err)
return nil, err
Expand All @@ -114,7 +114,7 @@ func (s *Server) AccountClientsGetClient(ctx context.Context, request AccountCli
}

func (s *Server) AccountClientsUpdateClient(ctx context.Context, request AccountClientsUpdateClientRequestObject) (AccountClientsUpdateClientResponseObject, error) {
session, err := CurrentUser(ctx)
session, err := s.Auth.CurrentUser(ctx)
if err != nil {
s.logger.Errorf("failed to get current user: %v", err)
return nil, err
Expand Down
145 changes: 99 additions & 46 deletions internal/api/gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions internal/api/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@ package api
import (
"auth/internal/domain"
"encoding/gob"
"os"

"github.com/gorilla/sessions"
)

func Init() {
gob.Register(&domain.User{})
store = sessions.NewCookieStore([]byte(os.Getenv("SESSION_SECRET")))
}
Loading

0 comments on commit 24032a8

Please sign in to comment.