Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support getting request authorization from a signature server #49

Open
markduan opened this issue Oct 24, 2019 · 7 comments
Open

Support getting request authorization from a signature server #49

markduan opened this issue Oct 24, 2019 · 7 comments
Assignees

Comments

@markduan
Copy link
Collaborator

No description provided.

@markduan markduan self-assigned this Oct 24, 2019
@markduan
Copy link
Collaborator Author

markduan commented Nov 5, 2019

implemented in commits ce9e3f2...6067247

@markduan markduan closed this as completed Nov 5, 2019
@senwa
Copy link

senwa commented Sep 11, 2021

sign() {
if (this.config.signature_server) {
return axios({
url: this.config.signature_server,
method: 'POST',
data: this.operation,
})
.then((res) => {
const { authorization } = res.data;

    this.operation.headers.authorization = authorization;

    return this;
  });
}

this.operation = new Signer(this.config.access_key_id, this.config.secret_access_key).sign(this.operation);
return Promise.resolve(this);

}

我的签名服务器是有token校验的,sdk里面也没放开axios设置header或者拦截的地方呀

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 12, 2021

Hi, 以 get_object 为例,我们可以先调用

getObjectRequest(object_key, options = {}) {

来构造出一个 getObjectRequest 对象,然后调用

applyQuerySignature(access_key_id, signature, expires) {
this.operation.params = Object.assign(this.operation.params, {
access_key_id,
signature,
expires,
});
return this;
}

或者

applySignature(signature) {
this.operation.headers.Authorization = signature;
return this;
}

来应用签名

@Xuanwo Xuanwo reopened this Sep 12, 2021
@senwa
Copy link

senwa commented Sep 18, 2021

你发的这个 应该是拿到签名之后的一些操作吧。
前提:你可以写一个签名服务器,但是这个签名服务器对于任何请求都要校验token认证,
然后你再写个demo试试,看一下只设置了签名服务器的地址是否能成功获取到签名。

我看源码里面只是拿在配置文件里面设置的signature_server签名服务器地址,然后内部直接调axios的post把operation里面的数据发到签名服务器了,没有开放一些口子,用于在请求时设置一些header或者token的地方,我是前端新手,不知道这么说能讲明白吗
if (this.config.signature_server) {
return axios({
url: this.config.signature_server,
method: 'POST',
data: this.operation,
}).

@senwa
Copy link

senwa commented Sep 18, 2021

可以加我微信咱们聊聊,MSen90

@Xuanwo
Copy link
Contributor

Xuanwo commented Sep 18, 2021

我大概明白你的意思了,我请 SDK 的维护者来看一下这个问题怎么解决。

ping @aprilyang for a look.

@aprilyang
Copy link
Collaborator

@senwa 你这边的需求是调用签名服务器允许传递自定义参数吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants