問題タブ [spring-security-rest]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
rest - Spring security rest plugin: Authentication failed, No AuthenticationProvider found
I am trying to integrate spring security rest plugin version 1.4.1 in my grails app, but facing some issue, I am doing like that:
Config.groovy setting:
and
As you can see from setting I am using Memcache for token storage, when I hit the url api/login
via a rest client I got 401 I enabled the logs In which it says that Authentication provider not found
Here is the logs:
My another point is that: If I make a request like localhost:8080/restspring/api/guest/controller/action
(for non-authenticated request) do I need to do some entry in URL mapping for this?My application uses the custom authentication provider. Any idea will be helpful for me, thanks.
rest - Grails + Spring Security レスト、POST リクエストを作成
ログイン (/api/login) でき、GET 要求を正常に行うことができました。ただし、POST リクエストの作成方法がわかりません。同様に、ログアウト (/api/logout) もできません。
コントローラー: (com.example.test)
Curl でログイン (および HTTP 応答):
GET リクエストのカール (メソッド シークレットの例):
POST リクエストは常にログイン ページにリダイレクトされます (トークンを渡した場合でも)。curl やレスト クライアント (Postman) などを使用してポスト リクエストを実行する方法の例を示してください。また、可能であれば、ログアウトする方法を示します (/api/logout)
構成
grails.plugin.springsecurity.rest.login.active=true grails.plugin.springsecurity.rest.login.endpointUrl='/api/login' grails.plugin.springsecurity.rest.login.failureStatusCode=401 grails.plugin.springsecurity. rest.login.useJsonCredentials=true grails.plugin.springsecurity.rest.login.usernamePropertyName='ユーザー名' grails.plugin.springsecurity.rest.login.passwordPropertyName='パスワード' grails.plugin.springsecurity.rest.logout.endpointUrl=' /api/logout' grails.plugin.springsecurity.rest.token.storage.useGorm = true grails.plugin.springsecurity.rest.token.storage.gorm.tokenDomainClassName="com.example.AuthenticationToken" grails.plugin.springsecurity.rest .token.storage.gorm.tokenValuePropertyName="tokenValue" grails.plugin.springsecurity.rest.token.storage.gorm.usernamePropertyName='ユーザー名'grails.plugin.springsecurity.rest.login.usernamePropertyName='ユーザー名' grails.plugin.springsecurity.rest.login.passwordPropertyName='パスワード' grails.plugin.springsecurity.rest.token.generation.useSecureRandom = true
失敗した POST の使用の試み
以下は、Curl と postman を使用して試したことの一部です。
また、郵便配達員を使用しています(添付画像):
rest - spring-security-rest プラグインのログアウト失敗
私はspring-security-rest:1.5.0.RC2を Grails 2.5.0 で使用しています。RestfulController を拡張したユーザープロファイル情報 UserProfileController のコントローラーを作成しました。ログインは、ユーザー プロファイルの取得と同様に正常に機能します。ただし、 \api\logout しようとすると、
ログアウト時に Bearer トークンを指定してユーザーを正しく見つけられるようにしていますが、静的ルールを使用してログアウト ページへのアクセスが許可されているかどうかを判断したいようで、アクセスが拒否されたと結論付けた場合はルールが見つからないためです。これは、最近のバージョンの grails で導入されたページのペシミスティック ロックが原因です。以下のログを参照してください。
Config.groovy の controllerAnnotations.staticRules で \api** が指定されていません
私のfilterChain.chainMapは次のようになります
実装しているコントローラのログアウト メソッドのセキュリティ アノテーションは何ですか? どうすればこれを機能させることができますか?
ありがとうございました
spring - RESTful API の Spring セキュリティ
Spring 4.1.6 とspring-boot-starter-data-rest
.
残りの API を完全に機能させるには、パズルの最後のピースであるセキュリティが必要です。今、春にはspring-security-*
そのタスクを支援できる独自のパッケージがあることに気付きました。
ユーザーが認証されていない場合、春はユーザーをログインにリダイレクトし、HTMLログインフォームを提供することを除いて、私は使用してみspring-security-config
ましたが、それは魅力のように機能します。spring-security-web
これは Restful API であるため、ユーザーが資格情報を持っていないか、特定のリソースを読み取るための十分なアクセス許可を持っていない場合に、JSON オブジェクトでエラーが返されるようにする必要があります。この質問をするのは私が初めてではなく、同じことを尋ねている人をウェブ全体で検索しましたが、探していたものを見つけることができませんでした. だから..春のセキュリティでこの方向に研究を続けるべきですか、それとも何かを見つけるべきですか?
どんなアドバイスでも大歓迎です、ありがとう
grails - カスタム X-Auth-Token ヘッダーを含む cURL リクエスト ログイン ページにリダイレクト
Alvaro の greach2014 リポジトリを使用して、Spring Security Rest プラグインの動作を実験しています。アプリケーションにログインして認証トークンを生成できます。ただし、get リクエストを送信しようとすると、ログイン ページにリダイレクトされます。ここに私のcURL応答があります
curl -X GET -i -H "X-Auth-Token: Bearer 6mp70e1h702ig5lp5l4j2dlbdbh5aiip" -H "Accept: application/json" http://localhost:8080/restful-grails-springsecurity-greach2014/categories
HTTP/1.1 302 Found
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=7D36AB88B14828CDB7085BBB8722A35F; Path=/restful-grails-springsecurity-greach2014/; HttpOnly
Location: http://localhost:8080/restful-grails-springsecurity-greach2014/login/auth
Content-Length: 0
Date: Tue, 07 Jul 2015 05:59:16 GMT
Bearer フラグも試してみましたが、結果は同じです
curl -X GET -i -H "X-Auth-Token: Bearer 6mp70e1h702ig5lp5l4j2dlbdbh5aiip" -H "Accept: application/json" http://localhost:8080/restful-grails-springsecurity-greach2014/categories
同様に、Authorization Bearer ヘッダーも試しましたが、タイムアウト例外が発生しました。
``` curl -X GET -i -H "Authorization: Bearer 6mp70e1h702ig5lp5l4j2dlbdbh5aiip" -H "Accept: application/json" http://localhost:8080/restful-grails-springsecurity-greach2014/categories HTTP/1.1 500 Internal Server Errorサーバー: Apache-Coyote/1.1 Content-Type: text/html;charset=utf-8 Content-Language: en Content-Length: 4472 Date: Tue, 07 Jul 2015 05:59:46 GMT Connection: close
Apache Tomcat/7.0.52 - エラー レポート
HTTP ステータス 500 - 値を待っているタイムアウト
タイプ例外レポート
値を待っているメッセージのタイムアウト
説明サーバーで内部エラーが発生したため、この要求を実行できませんでした。
例外
p>根本的な原因
p>note根本原因の完全なスタック トレースは、Apache Tomcat/7.0.52 ログで入手できます。
アパッチ トムキャット/7.0.52
grails - Grails Spring Security REST ログイン応答 HTTP コードをカスタマイズする方法
Grails アプリケーションに Spring Security プラグインと Spring Security REST プラグインを使用しており、パスワード変更ポリシーを実装しようとしています。フロントエンドでは、ログインしていないときにアプリケーションが 401 エラーをキャッチしていますが、パスワードの有効期限が切れている場合は、まったく同じ HTTP 応答が返されます。変える方法がないか探しています。
AbstractAuthenticationFailureEvent をキャッチして、それが AuthenticationFailureCredentialsExpired イベントによるものかどうかを判断できますが、そのイベントを取得して、これが単なるパスワード ログインの失敗ではないことを示す意味のあるものを API から送信する方法がわかりません。
余談ですが、パスワードを期限切れにしてそのポリシーを適用できるので、それは問題ではありません。主な問題は、この API のコンシューマが、失敗したユーザー名/パスワードのチャレンジと「パスワードを変更する必要がある」シナリオをどのように区別できるかです。