标签: oauth

WebSecurityConfigurerAdapter 覆盖 EnableResourceServer?

我有使用 spring oAuth2 的完美运行的 Spring Boot 应用程序。当我在主类上使用 @EnableResourceServer 时,它运行良好。但要为我在课下实现的服务启用 CORS

   @Configuration
    public class CorsConfiguration extends WebSecurityConfigurerAdapter {
        @Override
        protected void configure(HttpSecurity http) throws Exception {

            http.csrf().disable();
            http.cors();

        }
        @Bean
        public CorsConfigurationSource corsConfigurationSource() {
            final org.springframework.web.cors.CorsConfiguration configuration = new org.springframework.web.cors.CorsConfiguration();
            configuration.setAllowedOrigins(ImmutableList.of("*"));
            configuration.setAllowedMethods(ImmutableList.of("HEAD",
                    "GET", "POST", "PUT", "DELETE", "PATCH"));
            configuration.setAllowCredentials(true);
   configuration.setAllowedHeaders(ImmutableList.of("Authorization", "Cache-Control", "Content-Type"));
            final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
            source.registerCorsConfiguration("/**", configuration);
            return source;
        }
    }
Run Code Online (Sandbox Code Playgroud)

添加该类后,似乎请求未使用 oAuth 令牌进行验证。即使没有 oAuth 令牌的任何请求也可以访问服务。

我做错了什么?我不能两个都用吗?有什么特别的事情要做吗?有没有更好的方法来启用 CORS。(我试过@CrossOrigin 注释它没有用)

spring oauth spring-security spring-security-oauth2

0
推荐指数
1
解决办法
715
查看次数

永不过期 Salesforce 会话

我正在Salesforce OAuth我的应用程序中集成。将用户Salesforce帐户与我们的应用程序帐户映射后,我将访问令牌保存在数据库中。当用户请求从他的 Salesforce 帐户获取数据时,我只是使用该令牌来获取数据。遗憾的是,令牌有过期时间(最多 24 小时)。令牌过期后,用户必须再次将 salesforce 帐户与我们的应用程序连接。

有没有办法让 Salesforce 会话无限期地保持活动状态或任何其他方式来避免重复登录?

asp.net oauth salesforce

0
推荐指数
1
解决办法
2444
查看次数

Laravel 5.6 通过 oauth/令牌挂起

我已经使用 Laravel Passport 安装设置了一个新的 Laravel 5.6 安装。如果我使用 Postman向http://127.0.0.1/oauth/token发出帖子请求,我会得到一个有效的令牌:

要求

POST /oauth/token HTTP/1.1
Host: 127.0.0.1:8000
Content-Type: application/json
X-Requested-With: XMLHttpRequest
Cache-Control: no-cache
Postman-Token: 99529c07-0fe3-38a8-54cf-8b80a9dd5fbd

{ 
    "grant_type" : "password",
    "client_id" : 4, 
    "client_secret" : "Ib1UOS7BK12tFxOilqwea1XGJhrExbVYe8B7r8wK",
    "username" : "mail@mail.com",
    "password" : "password"
}
Run Code Online (Sandbox Code Playgroud)

回复:

{
    "token_type": "Bearer",
    "expires_in": 31536000,
    "access_token": "eyJ0eXAiOiJKV1.....",
    "refresh_token": "def5020026dfeb6f91f6a9....."
}
Run Code Online (Sandbox Code Playgroud)

我不希望我的用户直接访问它,所以我在 routes/web.php 文件中设置了一个路由:

Route::post('login', 'API\AuthController@login');
Run Code Online (Sandbox Code Playgroud)

我的 AuthController 看起来像:

<?php

namespace App\Http\Controllers\API;

use App\OAuth;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller as Controller;
use Illuminate\Support\Facades\Auth;
use Carbon\Carbon;
use App\User;

class AuthController extends …
Run Code Online (Sandbox Code Playgroud)

curl oauth laravel-passport laravel-5.6

0
推荐指数
1
解决办法
2650
查看次数

基于 Owin 的身份验证 - 在 Web api 中找不到“配置”方法

我以前从未从事过身份验证工作,想学习 asp.net web api 中的身份验证

我创建了一个项目,并在这个项目的帮助下开始工作 教程

但我收到以下错误

尝试加载应用程序时发生以下错误。- 在“OwinBasedToken.Startup、OwinBasedToken、Version=1.0.0.0、Culture=neutral、PublicKeyToken=null”类中找不到“配置”方法。要禁用 OWIN 启动发现,请在 web.config 中添加值为“false”的 appSetting owin:AutomaticAppStartup。要指定 OWIN 启动程序集、类或方法,请在 web.config 中添加带有完全限定启动类或配置方法名称的 appSetting owin:AppStartup。

描述:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其在代码中的来源的更多信息。

异常详细信息:System.EntryPointNotFoundException:尝试加载应用程序时发生以下错误。- 在“OwinBasedToken.Startup、OwinBasedToken、Version=1.0.0.0、Culture=neutral、PublicKeyToken=null”类中找不到“配置”方法。要禁用 OWIN 启动发现,请在 web.config 中添加值为“false”的 appSetting owin:AutomaticAppStartup。要指定 OWIN 启动程序集、类或方法,请在 web.config 中添加带有完全限定启动类或配置方法名称的 appSetting owin:AppStartup。

这是我的代码

WebApiConfig.cs

using System.Web.Http;

namespace OwinBasedToken
{
    public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional …
Run Code Online (Sandbox Code Playgroud)

c# oauth owin asp.net-web-api2

0
推荐指数
1
解决办法
1923
查看次数

System.Net.Sockets.SocketException: '一个现有的连接被远程主机强行关闭'与 SharePoint Online 低信任身份验证

我们正在使用 Oauth 在 Azure 中使用 SharePoint Online 对我们的云服务进行身份验证 - https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/three-authorization-systems-for-sharepoint-add -ins#low-trust并且我们收到此错误 - System.Net.Sockets.SocketException: '现有连接被远程主机强行关闭'

尝试下面的 clientContext.ExecuteQuery() 代码时。

Microsoft.SharePoint.Client.User spUser = null;
            try
            {
                using (clientContext)
                {
                    if (clientContext != null)
                    {
                        spUser = clientContext.Web.CurrentUser;

                        clientContext.Load(spUser);
                        clientContext.ExecuteQuery();

                        return spUser.LoginName.Split('|')[2];
                    }
                }
                return string.Empty;//no context = no id
            }
Run Code Online (Sandbox Code Playgroud)

这是 SharePoint 上下文的样子

知道这个问题可能是什么或如何解决这个问题吗?谢谢

sharepoint oauth acs sharepoint-online azure-cloud-services

0
推荐指数
1
解决办法
4321
查看次数

在 Flutter 中的 url 请求后从响应中获取数据

我正在尝试在 Flutter 中实现 OAuth 1.0。OAuth 1.0 的工作原理如下:OAuth 流程 我的应用程序要求请求令牌,该令牌由我要进行身份验证的服务提供。然后用户被重定向到属于服务的页面,在那里它授予访问我的应用程序数据的权限。现在我可以要求访问令牌,该令牌将用于签署每个未来的数据请求。

我将这个 OAuth 插件用于 OAuth 程序和Url Launcher 插件来执行请求,因为第一个插件等待 pin 数据,而我希望用户享受完全自动化的过程。我可以通过 OAuth 库请求请求令牌,但以下代码仅启动 url,因此我无法从响应中检索数据。

if (await canLaunch(url)) {
  await launch(url, forceWebView: true, enableJavaScript: true);
} else {
  throw 'Could not launch $url';
}
Run Code Online (Sandbox Code Playgroud)

用户交互后如何获取数据?

oauth flutter

0
推荐指数
1
解决办法
454
查看次数

Google OAuth 同意屏幕不显示新请求的敏感范围

我已请求 Google 批准敏感范围。到目前为止,该应用程序正在访问基本的姓名和电子邮件数据。但是,新请求的范围不会显示在同意屏幕上。Google 要求我与新的 OAuth 同意屏幕共享视频,但在他们更新之前我无法显示新范围。我究竟做错了什么?我查找了其他问题和资源,但没有找到与敏感范围相关的特定于此问题的任何问题。在此输入图像描述

在此输入图像描述 在此输入图像描述

screen oauth scopes

0
推荐指数
1
解决办法
1486
查看次数

如何在不使用PEAR :: DB的情况下重新编写此代码?

我正在尝试使用Twitter OAuthLog到Pligg安装Pligg Twitter登录模块.

我从上面的页面下载了ZIP文件,并按照所有说明进行操作.然后我意识到其中一个文件正在使用PEAR,这是我的托管公司没有提供的.

整个代码来自confirm.php:

如何重写此代码,以便我不必使用PEAR?这甚至可能吗?我是PHP的新手.

<?php
include 'EpiCurl.php';
include 'EpiOAuth.php';
include 'EpiTwitter.php';
include 'secret.php';
require_once 'DB.php';

$twitterObj = new EpiTwitter($consumer_key, $consumer_secret);

$twitterObj->setToken($_GET['oauth_token']);
$token = $twitterObj->getAccessToken();
$twitterObj->setToken($token->oauth_token, $token->oauth_token_secret);

try {
    setcookie('oauth_token', $token->oauth_token);
    setcookie('oauth_token_secret', $token->oauth_token_secret);

    $twitterInfo= $twitterObj->get_accountVerify_credentials();
    $twitterUserName = $twitterInfo->screen_name;
    $twitterAvatar = $twitterInfo->profile_image_url;
} catch (Exception $e) {
    die("Sorry, there was an error connecting to twitter:".$e->getMessage());
}

$DB =& DB::connect('mysqli://USER:PASS@localhost/DB');
if (DB::isError($DB))
{
    echo 'Cannot connect to database: ' . $DB->getMessage();
} …
Run Code Online (Sandbox Code Playgroud)

php twitter pear oauth

-2
推荐指数
1
解决办法
281
查看次数

使用Facebook PHP-SDK时语法错误,意外'{'

我正在尝试在Facebook上获取我的团队的Flash项目,但我无法使用任何PHP-SDK示例.我已经按照几个例子,比如github上的这个新例子(这里).但是,我一直得到一个解析错误:

解析错误:语法错误,第36行的/home/content/r/a/s/rashomon/html/projects/facebook/test/hellomyflash/index.php中的意外"{"

我下载了最新的PHP-SDK.这是我的文件结构:

.../hellomyflash/

   index.php

   src/base_facebook.php

   src/facebook.php

   src/fb_ca_chain_bundle.crt
Run Code Online (Sandbox Code Playgroud)

我在index.php中改变的唯一两行是appId和secret.

index.php:

<?php
/**
 * Copyright 2011 Facebook, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may
 * not use this file except in compliance with the License. You may obtain
 * a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" …
Run Code Online (Sandbox Code Playgroud)

php flash facebook oauth facebook-php-sdk

-3
推荐指数
1
解决办法
974
查看次数