oauth

Generate OAuth1 signature in C#

女生的网名这么多〃 提交于 2021-02-04 18:38:05
问题 I've a big problem. I work on a UWP Windows 10 application in C# and i would like to use OAuth 1. All is almost okay BUT the signature is wrong. However, I found the sample code on the Microsoft GitHub. Obviously, I have done some modifications... My code : private async Task GoCo() { String LifeInvaderUrl = "http://stage.api.lolilolz.be/v8/login"; string timeStamp = GetTimeStamp(); string nonce = GetNonce(); string consumerKey = "noob-stage"; string consumerSecret = "TOPSECRETxxXXxx"; string

官方Spring Boot starters整理

不问归期 提交于 2021-02-02 18:45:08
Spring Boot starters Spring Boot 的功能组件(例如 spring-boot-starter-actuator、 spring-boot-starter-data-redis 等)的步骤非常简单,用著名的把大象放冰箱的方法来概括的话,有以下三步就可以完成组件功能的使用: STEP 1 在 pom 文件中引入对应的包,例如: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> STEP 2 在应用配置文件中加入相应的配置,配置都是组件约定好的,需要查看官方文档或者相关说明。有些比较复杂的组件,对应的参数和规则也相应的较多,有点可能多大几十上百了。 STEP 3 以上两步都正常的情况下,我们就可以使用组件提供的相关接口来开发业务功能了。下面我整理了官方提供的starter.我们来看一看. 1、application starters 应用程序级的 Starters <table> <thead> <tr> <th>Starter 名称</th> <th>Starter 描述</th> </tr> </thead> <tbody> <tr> <td>spring

腾讯工程师经验:如何写一手好代码?

余生长醉 提交于 2021-01-31 08:52:54
导读:如何写一手好代码,本文值得大伙一读哦。 前言 作为公司代码委员会 golang 分会的理事,我 Review 了很多代码,看了很多别人的 review 评论。发现不少同学 code review 与写出好代码的水平有待提高。在这里,想分享一下我的一些理念和思路。 为什么技术人员包括 leader 都要做 Code Review 谚语曰: 'Talk Is Cheap, Show Me The Code'。 知易行难,知行合一难。嘴里要讲出来总是轻松,把别人讲过的话记住,组织一下语言,再讲出来,很容易。绝知此事要躬行。设计理念你可能道听途说了一些,以为自己掌握了,但是你会做么?有能力去思考、改进自己当前的实践方式和实践中的代码细节么?不客气地说,很多人仅仅是知道并且认同了某个设计理念,进而产生了一种虚假的安心感---自己的技术并不差。但是,他根本没有去实践这些设计理念,甚至根本实践不了这些设计理念,从结果来说,他懂不懂这些道理/理念,有什么差别?变成了自欺欺人。 代码,是设计理念落地的地方,是技术的呈现和根本。同学们可以在 review 过程中做到落地沟通,不再是空对空的讨论,可以在实际问题中产生思考的碰撞,互相学习,大家都掌握团队里积累出来最好的实践方式!当然,如果 leader 没时间写代码,仅仅是 review 代码,指出其他同学某些实践方式不好,要给出好的实践的意见

Feign自定义异常处理

百般思念 提交于 2021-01-31 05:30:16
问题 FeignClient接口调用异常时,默认会在接口原始异常信息基础上包装一层Feign Request信息: code: -1 message: "[401 ] during [POST] to [http://uaa-center-server/oauth/token?grant_type=pin_code&username=sujingjun%40dhgate.com&password=liangb1231aaa&userType=1&verificationCode=0ee3674f07a7e3c7c3d87b4fb779afe3dq] [UaaServerClient#postAccessToken(String,String,String,Integer,String)]: [{"success":false,"code":401,"message":"username or password error."}]" success: false 业务系统无法通过异常类的不能直接在异常信息中看出原始方法抛出的异常,需要做异常字符串截取等处理。Feign封装过的异常,不能直接在异常信息中看出原始方法抛出的异常。当调用服务时,如果服务返回的状态码不是200,就会进入到Feign的ErrorDecoder中,因此如果我们要解析异常信息,就要重写ErrorDecoder:

一次测试的全过程

大憨熊 提交于 2021-01-30 08:50:59
身份认证 不要使用 Basic Auth 使用标准的认证协议 (比如 JWT, OAuth). 不要再造 Authentication , token generating , password storing 这些轮子, 使用标准的. JWT (JSON Web Token) 使用随机复杂的秘钥 ( JWT Secret ) 以增加暴力破解的难度. 不要在请求体中直接提取数据, 要对数据进行加密 ( HS256 or RS256 ). 是 token 的过期时间尽量的短 ( TTL , RTTL ) . 不要在 JWT 的请求体重存放敏感数据, 它是可破解的 easily. OAuth 授权或认证协议 始终在后台验证 redirect_uri 只允许白名单的 url. 每次交换令牌的时候不要加 token (不允许 response_type=token ). 使用 state 参数并填充随机的哈希数来防止跨站请求伪造(CSRF). 对不同的应用分别定义默认的作用于和各自有效的作用域参数. 访问 限制流量来防止 DDos 攻击和暴力攻击. 在服务端使用 HTTPS 协议来防止 MITM 攻击. 使用 HSTS 协议防止 SSLStrip 攻击. 输入 使用与操作相符的 HTTP 操作函数 , GET (读取) , POST (创建) , PUT (替换/更新) and

How to log on to user mailbox from service using oAuth and MS Graph API

笑着哭i 提交于 2021-01-29 18:39:56
问题 I am adding oAuth authentication support to daemon application. In case of IMAP, application logs on to every mailbox by specifying userID/password. Office365 oAuth access requires application registration and uses Clients Credential Grant flow. In this case, application authenticates with Azure AD once and accesses every mailbox using oAuth token. This authentication flow requires significant changes of existing code base. I would like to access mailbox in logically same way as IMAP (specify

How does Discord connect to third party APIs?

▼魔方 西西 提交于 2021-01-29 17:33:10
问题 I am trying to reproduce something similar in my app. I only see things like OAuth where you can "login" with an external API and a new user will be created/authenticated with their third party credentials. Or alternatively some authorization flow where access tokens must be refreshed every hour or so. Discord, however, connects to these APIs and does not create or login a new user, they only access the user's data from that external API and presents it on the Discord GUI. Furthermore, as a

How to log on to user mailbox from service using oAuth and MS Graph API

烈酒焚心 提交于 2021-01-29 12:20:35
问题 I am adding oAuth authentication support to daemon application. In case of IMAP, application logs on to every mailbox by specifying userID/password. Office365 oAuth access requires application registration and uses Clients Credential Grant flow. In this case, application authenticates with Azure AD once and accesses every mailbox using oAuth token. This authentication flow requires significant changes of existing code base. I would like to access mailbox in logically same way as IMAP (specify

Google oauth2 and SPA

寵の児 提交于 2021-01-29 11:12:37
问题 I have an api and an Angular SPA that's completely separate from it, and they have different origins/hosts, I figured out the implementation to be like this: The user gets into the SPA, the SPA gets a CSRF token from the api (I'll have an endpoint that generates such tokens), the user clicks a 'sign in with Google' button that redirects him to Google's consent page (the CSRF token will be sent as a state field, also the client id will be sent), after the user's agreement Google Auth redirects

How do I get tokens for a Google Web application using oauth.tools?

不想你离开。 提交于 2021-01-29 10:02:06
问题 I would like to use OAuth.tools to get an access token, refresh token, and ID token for my Web application that I've setup in Google Identity Platform? I'm unsure how to configure OAuth.tools to communicate with Google's OAuth server, and there are various flows, but I'm not sure which applies to my Web application. What should I fill in here, for instance, to make it work with OAuth.tools: 回答1: To do this, you need to: Configure the client at Google (the screenshot above) Setup an