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

HI ,zihe ,let me help you #19

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
post_logout_redirect_uri 真正理解了 identityServer3 服务端处理 客户端post的
logout -redirect -uri的方式!
  • Loading branch information
tearf001 committed Jan 23, 2017
commit 0d05f91477d8ef4f9e9607116331ad8f62a2e835
66 changes: 3 additions & 63 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,81 +19,21 @@ import 'nprogress/nprogress.css'
//应用主组件


import Axios from 'axios';
let instance;
import {axiosInstance,oidcMgr } from './services';
//如果全局使用,定义在原型上面
Vue.prototype.$http = instance = Axios.create({
baseURL: 'https://10.36.111.213/api',
withCredentials: false
});

const appSettings = {
client_id: "tripgalleryimplicit",
tripGalleryAPI: "https://10.36.111.213/",
STSauthority: "https://10.36.111.213/identity",
};

const post_logout_redirect_uri = window.location.protocol + "//" + window.location.host + "/posthandler.html?op=logout";
const redirect_uri = window.location.protocol + "//" + window.location.host + "/posthandler.html?op=callback";
const silent_redirect_uri = window.location.protocol + "//" + window.location.host + "/posthandler.html?op=silent_refresh";
const oidcConfig = {
client_id: appSettings.client_id,
redirect_uri: redirect_uri,
post_logout_redirect_uri: post_logout_redirect_uri,
response_type: "id_token token",
scope: "openid profile gallerymanagement",
authority: appSettings.STSauthority,
silent_redirect_uri: silent_redirect_uri,
silent_renew: true,
with_credentials: false
//acr_values: "2fa"
};
//import * as Oidc from 'oidc-client';
//console.log('---Oidc---------',Oidc);
// const mgr = new Oidc.OidcClient(oidcConfig);


import 'oidc-token-manager';

const mgr = new OidcTokenManager(oidcConfig);

Vue.prototype.$oidcMgr = mgr;

instance.interceptors.request.use(function (cfg) {
debugger;
if (mgr.expired) {
debugger;
console.log('------------访问令牌过期,重新访问-------------');
localStorage.setItem('last-route',vm.$route.path)
mgr.redirectForToken();
}
//api服务的规则:如果是公共api应采用jsonp访问,否则必须鉴权
if (cfg.url.indexOf(appSettings.tripGalleryAPI) === 0) {
console.log('---!---', cfg)
debugger;
cfg.headers.Authorization = 'Bearer ' + mgr.access_token;
console.log(cfg.headers.Authorization);
}
return cfg;
}, function (error) {
console.log(`--interceptors请求错误--`, error);
return error;
});
Vue.prototype.$http = axiosInstance;
Vue.prototype.$oidcMgr = oidcMgr;

Vue.use(ElementUI);
Vue.use(VueRouter);
Vue.use(Vuex);


import {routes} from './routes.config.js'


const router = new VueRouter({
routes,
history: false,
saveScrollPosition: true,
transitionOnLoad: true

});
//console.log(router.options)
router.beforeEach((to, from, next) => {
Expand Down
2 changes: 1 addition & 1 deletion src/posthandler.js

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

1 change: 1 addition & 0 deletions src/services.js

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

2 changes: 1 addition & 1 deletion src/vuex/modules/abc.js

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