Identityserver 实现token认证主要参考https://www.cnblogs.com/zhurunlai/p/10564508.html
这位博主的介绍很详细,实际起服务时有个bug,报“invalid token”,原因是因为没有定义scope,这个是必须自己配置的,默认的不可以
2.如果用.AddDeveloperSigningCredential(),服务会自动生成一个临时的jwk文件,作为签名文件,实际使用建议自己利用openssl生成配置文件,
可以参考https://www.cnblogs.com/fengchao1000/p/10254903.html
3.部署时用了nginx,本地授权路径指向服务器路径,但是从服务器获取的token在本地unAuthrize,访问configuration ,例如我服务的域名是http://example.com/Api,配置文件显示的却是http://localhost:5000,此时需要去修改nginx的
配置文件:
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
重启服务后配置文件路径显示http://example.com/.well-konwn.....,但是实际上我需要他显示http://example.com/Api/.well-konwn.....,,原来可以用PublicOrigin,
但Identityserver4中没有了,在StartUp中添加以下代码解决
app.Use(async (ctx, next) =>//解决nginx配置问题
{
ctx.SetIdentityServerOrigin(“http://example.comj/Api”);
await next();
});