Skip to content

Commit

Permalink
maintain!: remove ununsed create token body (#1216) (#1497)
Browse files Browse the repository at this point in the history
- remove unused create token request body that specified user id
- remove api createtokenrequest
  • Loading branch information
BruceMacD authored Apr 7, 2022
1 parent c7970fa commit ac3c509
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 47 deletions.
4 changes: 2 additions & 2 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ func (c Client) DeleteAccessKey(id uid.ID) error {
return delete(c, fmt.Sprintf("/v1/access-keys/%s", id))
}

func (c Client) CreateToken(req *CreateTokenRequest) (*CreateTokenResponse, error) {
return post[CreateTokenRequest, CreateTokenResponse](c, "/v1/tokens", req)
func (c Client) CreateToken() (*CreateTokenResponse, error) {
return post[EmptyRequest, CreateTokenResponse](c, "/v1/tokens", &EmptyRequest{})
}

func (c Client) Introspect() (*Introspect, error) {
Expand Down
8 changes: 0 additions & 8 deletions api/token.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
package api

import (
"github.com/infrahq/infra/uid"
)

type CreateTokenRequest struct {
UserID uid.ID `json:"userID" validate:"required"`
}

type CreateTokenResponse struct {
Expires Time `json:"expires"`
Token string `json:"token"`
Expand Down
20 changes: 0 additions & 20 deletions docs/api/openapi3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3462,26 +3462,6 @@
"post": {
"description": "CreateToken",
"operationId": "CreateToken",
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"userID": {
"example": "4yJ3n3D8E2",
"format": "uid",
"pattern": "[\\da-zA-HJ-NP-Z]{1,11}",
"type": "string"
}
},
"required": [
"userID"
],
"type": "object"
}
}
}
},
"responses": {
"400": {
"content": {
Expand Down
17 changes: 1 addition & 16 deletions internal/cmd/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,7 @@ func tokensCreate() error {
return err
}

config, err := currentHostConfig()
if err != nil {
return err
}

id := config.PolymorphicID
if id == "" {
return fmt.Errorf("no active identity")
}

identityID, err := id.ID()
if err != nil {
return err
}

token, err := client.CreateToken(&api.CreateTokenRequest{UserID: identityID})
token, err := client.CreateToken()
if err != nil {
if errors.Is(err, api.ErrForbidden) {
fmt.Fprintln(os.Stderr, "Session has expired.")
Expand Down
2 changes: 1 addition & 1 deletion internal/server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ func (a *API) DeleteDestination(c *gin.Context, r *api.Resource) error {
return access.DeleteDestination(c, r.ID)
}

func (a *API) CreateToken(c *gin.Context, r *api.CreateTokenRequest) (*api.CreateTokenResponse, error) {
func (a *API) CreateToken(c *gin.Context, r *api.EmptyRequest) (*api.CreateTokenResponse, error) {
if access.CurrentIdentity(c) != nil {
currentIDP, err := access.CurrentIdentityProvider(c)
if err != nil {
Expand Down

0 comments on commit ac3c509

Please sign in to comment.