moving away from authorization header due to limitations

This commit is contained in:
Roland Osborne 2022-03-19 21:04:14 -07:00
parent 0bce0c481c
commit d6dff01317
6 changed files with 47 additions and 9 deletions

View File

@ -601,6 +601,7 @@ paths:
- account - account
description: Generate token to attach an app to the account. Access granted to account's username and password. description: Generate token to attach an app to the account. Access granted to account's username and password.
operationId: add-account-app operationId: add-account-app
security:
- basicAuth: [] - basicAuth: []
responses: responses:
'201': '201':
@ -748,8 +749,13 @@ paths:
- profile - profile
description: Download base64 decoded data of profile image. Access granted to app tokens of account holder. description: Download base64 decoded data of profile image. Access granted to app tokens of account holder.
operationId: get-profile-image operationId: get-profile-image
security: parameters:
- bearerAuth: [] - name: agent
in: query
description: agent token
required: false
schema:
type: string
responses: responses:
'200': '200':
description: success description: success
@ -2968,9 +2974,9 @@ components:
accountStorage: accountStorage:
type: integer type: integer
format: int64 format: int64
openAccess openAccess:
type: boolean type: boolean
accountLimit accountLimit:
type: integer type: integer
format: int64 format: int64
@ -2996,6 +3002,31 @@ components:
searchable: searchable:
type: boolean type: boolean
AccountProfile:
type: object
required:
- guid
- revision
- node
properties:
accountId:
type: integer
format: uint32
guid:
type: string
handle:
type: string
name:
type: string
description:
type: string
location:
type: string
imageSet:
type: boolean
disabled:
type: boolean
Profile: Profile:
type: object type: object
required: required:
@ -3643,3 +3674,4 @@ components:

View File

@ -11,7 +11,7 @@ import (
func GetProfileImage(w http.ResponseWriter, r *http.Request) { func GetProfileImage(w http.ResponseWriter, r *http.Request) {
var data []byte var data []byte
account, code, err := ParamAppToken(r, true); account, code, err := ParamAgentToken(r, true);
if err != nil { if err != nil {
ErrResponse(w, code, err) ErrResponse(w, code, err)
return return

View File

@ -77,10 +77,10 @@ func BearerAccountToken(r *http.Request) (*store.AccountToken, error) {
return &accountToken, nil return &accountToken, nil
} }
func ParamAppToken(r *http.Request, detail bool) (*store.Account, int, error) { func ParamAgentToken(r *http.Request, detail bool) (*store.Account, int, error) {
// parse authentication token // parse authentication token
target, access, err := ParseToken(r.FormValue("token")) target, access, err := ParseToken(r.FormValue("agent"))
if err != nil { if err != nil {
return nil, http.StatusBadRequest, err return nil, http.StatusBadRequest, err
} }

View File

@ -102,7 +102,7 @@ func TestProfileUpdate(t *testing.T) {
APP_TOKENAPP, set.A.Token, &profile, nil)) APP_TOKENAPP, set.A.Token, &profile, nil))
// retrieve profile image // retrieve profile image
data, hdr, err = ApiTestData(GetProfileImage, "GET", "/profile/image?token=" + set.A.Token, nil, nil, data, hdr, err = ApiTestData(GetProfileImage, "GET", "/profile/image?agent=" + set.A.Token, nil, nil,
APP_TOKENAPP, set.A.Token, 0, 0) APP_TOKENAPP, set.A.Token, 0, 0)
assert.NoError(t, err) assert.NoError(t, err)

View File

@ -25,6 +25,9 @@ export function Identity() {
<div onClick={() => actions.editProfile()}>Edit Profile</div> <div onClick={() => actions.editProfile()}>Edit Profile</div>
</Menu.Item> </Menu.Item>
<Menu.Item key="1"> <Menu.Item key="1">
<div onClick={() => actions.editLabels()}>Manage Labels</div>
</Menu.Item>
<Menu.Item key="2">
<div onClick={() => actions.logout()}>Sign Out</div> <div onClick={() => actions.logout()}>Sign Out</div>
</Menu.Item> </Menu.Item>
</Menu> </Menu>
@ -32,7 +35,7 @@ export function Identity() {
return ( return (
<IdentityWrapper> <IdentityWrapper>
<Dropdown overlay={menu} overlayStyle={{ minWidth: 0 }} trigger={['click']} placement="right"> <Dropdown overlay={menu} overlayStyle={{ minWidth: 0 }} trigger={['click']} placement="rightTop">
<div> <div>
<div class="container"> <div class="container">
<div class="avatar"> <div class="avatar">

View File

@ -15,6 +15,9 @@ export function useIdentity() {
logout: async () => { logout: async () => {
app.actions.logout() app.actions.logout()
}, },
editLabels: () => {
console.log("EDIT LABELS");
},
editProfile: () => { editProfile: () => {
navigate('/user/profile'); navigate('/user/profile');
} }